Skip to content

Commit

Permalink
Chore: Add Keycloak model as a dependency to crd-generator tests
Browse files Browse the repository at this point in the history
And generate crd from it to verify that it can be done without StackOverwlows and other errors.
No other verifications are performed.
  • Loading branch information
xRodney committed Oct 21, 2022
1 parent 4a182f7 commit a7cced0
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crd-generator/test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
<artifactId>validation-api</artifactId>
<scope>test</scope>
</dependency>

<!-- Keycloak model for testing -->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.fabric8.crd.generator.keycloak;

import org.keycloak.representations.idm.ComponentExportRepresentation;
import org.keycloak.representations.idm.GroupRepresentation;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.authorization.ScopeRepresentation;

import io.fabric8.crd.generator.annotation.SchemaSwap;
import io.fabric8.kubernetes.api.model.Namespaced;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.Version;

@Group("sample.fabric8.io")
@Version("v1alpha1")
@SchemaSwap(originalType = ComponentExportRepresentation.class, fieldName = "subComponents")
@SchemaSwap(originalType = GroupRepresentation.class, fieldName = "subGroups")
@SchemaSwap(originalType = ScopeRepresentation.class, fieldName = "policies")
@SchemaSwap(originalType = ScopeRepresentation.class, fieldName = "resources")
public class KeycloakRealm extends CustomResource<RealmRepresentation, Void> implements Namespaced {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.crd.generator.keycloak;

import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionVersion;
import io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps;
import io.fabric8.kubernetes.client.utils.Serialization;
import org.junit.jupiter.api.Test;

import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

class KeycloakRealmCRDTest {

@Test
void testCrd() {
CustomResourceDefinition d = Serialization.unmarshal(getClass().getClassLoader()
.getResourceAsStream("META-INF/fabric8/keycloakrealms.sample.fabric8.io-v1.yml"),
CustomResourceDefinition.class);
assertNotNull(d); // just make sure it generates
}
}
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
<awaitility.version>4.2.0</awaitility.version>
<approvaltests.version>18.5.0</approvaltests.version>
<mockito.version>4.8.0</mockito.version>
<!-- Keycloak model version for crd-generator testing -->
<keycloak.version>19.0.3</keycloak.version>

<conscrypt-openjdk-uber.bundle.version>1.4.2_1</conscrypt-openjdk-uber.bundle.version>
<generex.version>1.0.2</generex.version>
Expand Down Expand Up @@ -841,6 +843,14 @@
<version>${approvaltests.version}</version>
<scope>test</scope>
</dependency>

<!-- Keycloak model for crd-generator testing -->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>${keycloak.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit a7cced0

Please sign in to comment.