Skip to content

Commit

Permalink
adding automation rest tests of oidc auth module for keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed May 26, 2023
1 parent d1a1602 commit a2acab5
Show file tree
Hide file tree
Showing 21 changed files with 443 additions and 428 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ private RemoteModuleWebSecurityConfiguration createJwtResourceServerConfiguratio
configuration.setSequenceSuffix(sequenceSuffix);

JwtAuthenticationConverter jwtAuthenticationConverter = new JwtAuthenticationConverter();
if (resourceServer.getNameOfUsernameClaim() != null) {
if (resourceServer.getJwt() != null && resourceServer.getJwt().getNameOfUsernameClaim() != null) {
jwtAuthenticationConverter.setPrincipalClaimName(resourceServer.getJwt().getNameOfUsernameClaim());
} else if (resourceServer.getNameOfUsernameClaim() != null) {
jwtAuthenticationConverter.setPrincipalClaimName(resourceServer.getNameOfUsernameClaim());
}
configuration.addAuthenticationProvider(getObjectObjectPostProcessor().postProcess(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2220,6 +2220,9 @@ protected <O extends ObjectType> PrismObject<O> parseObject(File file) throws Sc
return prismContext.parseObject(file);
}

protected <O extends ObjectType> PrismObject<O> parseObject(String stringData) throws SchemaException, IOException {
return prismContext.parseObject(stringData);
}
protected void displayCleanup() {
TestUtil.displayCleanup(getTestNameShort());
}
Expand Down
19 changes: 19 additions & 0 deletions testing/rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,23 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>restAuthenticationTest</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skipTests>false</skipTests>
<suiteXmlFiles>
<suiteXmlFile>testng-authentication.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

public abstract class TestAbstractAuthentication extends AbstractRestServiceInitializer {

protected static final File MIDPOINT_HOME = new File("target/midpoint-home");
protected static final File BASE_AUTHENTICATION_DIR = new File("src/test/resources/authentication/");
protected static final File BASE_REPO_DIR = new File(BASE_AUTHENTICATION_DIR,"repo/");

Expand Down Expand Up @@ -86,4 +87,12 @@ protected void replaceSecurityPolicy(File securityPolicy) throws CommonException
addObject(secPolicy, executeOptions().overwrite(), task, result);
getDummyAuditService().clear();
}

protected void replaceSecurityPolicy(String securityPolicy) throws CommonException, IOException {
Task task = getTestTask();
OperationResult result = task.getResult();
PrismObject<SecurityPolicyType> secPolicy = parseObject(securityPolicy);
addObject(secPolicy, executeOptions().overwrite(), task, result);
getDummyAuditService().clear();
}
}

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit a2acab5

Please sign in to comment.