Skip to content
Snippets Groups Projects
Commit aaea99cb authored by OZGCloud's avatar OZGCloud
Browse files

OZG-3961 - add readme, refactor KeycloakUserSpec

parent ad40db18
Branches
Tags
No related merge requests found
# OZG Operator
## Installation
### CRDs im Cluster anlegen
kubectl apply -f doc/crds/*yaml
### Service Account anlegen
kubectl apply -f doc/ServiceAccount/*yaml
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: kopkeycloakrealms.api.kop-stack.de
spec:
group: api.kop-stack.de
names:
kind: OzgKeycloakRealm
listKind: OzgKeycloakRealmList
plural: ozgkeycloakrealms
singular: ozgkeycloakrealm
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: OzgKeycloakRealm is the Schema for the keycloak realms API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec defines the desired state of Keycloak
type: object
x-kubernetes-preserve-unknown-fields: true
status:
description: Status defines the observed state of Keycloak
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
served: true
storage: true
subresources:
status: {}
...@@ -67,7 +67,7 @@ interface KeycloakUserMapper { ...@@ -67,7 +67,7 @@ interface KeycloakUserMapper {
@Named("mapClientRoles") @Named("mapClientRoles")
default Map<String, List<String>> mapClientRoles(List<OzgKeycloakUserSpec.KeycloakUserSpecClientRole> clientRoles) { default Map<String, List<String>> mapClientRoles(List<OzgKeycloakUserSpec.KeycloakUserSpecClientRole> clientRoles) {
return clientRoles.stream() return clientRoles.stream()
.collect(Collectors.groupingBy(KeycloakUserSpecClientRole::getName, .collect(Collectors.groupingBy(KeycloakUserSpecClientRole::getClientName,
Collectors.mapping(KeycloakUserSpecClientRole::getRole, Collectors.toList()))); Collectors.mapping(KeycloakUserSpecClientRole::getRoleName, Collectors.toList())));
} }
} }
...@@ -87,12 +87,10 @@ public class OzgKeycloakUserSpec { ...@@ -87,12 +87,10 @@ public class OzgKeycloakUserSpec {
@AllArgsConstructor @AllArgsConstructor
public static class KeycloakUserSpecClientRole { public static class KeycloakUserSpecClientRole {
@JsonProperty("name") @JsonProperty("client_name")
// TODO rename to clientName private String clientName;
private String name;
@JsonProperty("role") @JsonProperty("role_name")
// TODO rename to roleId private String roleName;
private String role;
} }
} }
...@@ -113,7 +113,7 @@ class KeycloakUserMapperTest { ...@@ -113,7 +113,7 @@ class KeycloakUserMapperTest {
.hasSize(1); .hasSize(1);
assertThat(mappedRoles.get(KeycloakUserSpecUserTestFactory.CLIENT_NAME)) assertThat(mappedRoles.get(KeycloakUserSpecUserTestFactory.CLIENT_NAME))
.contains(KeycloakUserSpecUserTestFactory.ROLE1.getRole(), KeycloakUserSpecUserTestFactory.ROLE2.getRole()); .contains(KeycloakUserSpecUserTestFactory.ROLE1.getRoleName(), KeycloakUserSpecUserTestFactory.ROLE2.getRoleName());
} }
@Test @Test
...@@ -121,7 +121,7 @@ class KeycloakUserMapperTest { ...@@ -121,7 +121,7 @@ class KeycloakUserMapperTest {
var keycloakUser = mapper.toUserRepresentation(OzgKeycloakUserSpecTestFactory.create()); var keycloakUser = mapper.toUserRepresentation(OzgKeycloakUserSpecTestFactory.create());
assertThat(keycloakUser.getClientRoles().get(KeycloakUserSpecUserTestFactory.CLIENT_NAME)).hasSize(2) assertThat(keycloakUser.getClientRoles().get(KeycloakUserSpecUserTestFactory.CLIENT_NAME)).hasSize(2)
.contains(KeycloakUserSpecUserTestFactory.ROLE1.getRole(), KeycloakUserSpecUserTestFactory.ROLE2.getRole()); .contains(KeycloakUserSpecUserTestFactory.ROLE1.getRoleName(), KeycloakUserSpecUserTestFactory.ROLE2.getRoleName());
} }
} }
......
...@@ -19,8 +19,8 @@ class KeycloakUserSpecUserTestFactory { ...@@ -19,8 +19,8 @@ class KeycloakUserSpecUserTestFactory {
public static final KeycloakUserSpecUserGroup GROUP2 = KeycloakUserSpecUserGroup.builder().name("GROUP2").build(); public static final KeycloakUserSpecUserGroup GROUP2 = KeycloakUserSpecUserGroup.builder().name("GROUP2").build();
public static final String CLIENT_NAME = "alfa"; public static final String CLIENT_NAME = "alfa";
public static final KeycloakUserSpecClientRole ROLE1 = KeycloakUserSpecClientRole.builder().name(CLIENT_NAME).role("ROLE1").build(); public static final KeycloakUserSpecClientRole ROLE1 = KeycloakUserSpecClientRole.builder().clientName(CLIENT_NAME).roleName("ROLE1").build();
public static final KeycloakUserSpecClientRole ROLE2 = KeycloakUserSpecClientRole.builder().name(CLIENT_NAME).role("ROLE2").build(); public static final KeycloakUserSpecClientRole ROLE2 = KeycloakUserSpecClientRole.builder().clientName(CLIENT_NAME).roleName("ROLE2").build();
public static KeycloakUserSpecUser create() { public static KeycloakUserSpecUser create() {
return createBuiler().build(); return createBuiler().build();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment