Skip to content

Commit

Permalink
Add Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
f11h committed Jul 26, 2023
1 parent 121f326 commit dcb6b46
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;

@TestPropertySource(properties = {
"import.managed.authentication-flow=no-delete",
Expand All @@ -48,6 +49,8 @@
"import.managed.role=no-delete",
"import.managed.client=no-delete",
"import.managed.client-authorization-resources=no-delete",
"import.managed.client-authorization-policies=no-delete",
"import.managed.client-authorization-scopes=no-delete",
})
@SuppressWarnings({"java:S5961", "java:S5976"})
class ImportManagedNoDeleteIT extends AbstractImportIT {
Expand Down Expand Up @@ -155,5 +158,21 @@ private void assertRealm() {
.stream().filter(resource -> clientResourcesList.contains(resource.getName()))
.collect(Collectors.toList());
assertThat(createdClientResourcesList, hasSize(2));

int createdScopesCount = createdRealm
.getClients()
.stream().filter(client -> Objects.equals(client.getName(), "moped-client")).findAny()
.orElseThrow(() -> new RuntimeException("Cannot find client 'moped-client'"))
.getAuthorizationSettings().getScopes()
.size();
assertThat(createdScopesCount, is(4));

int createdPoliciesCount = createdRealm
.getClients()
.stream().filter(client -> Objects.equals(client.getName(), "moped-client")).findAny()
.orElseThrow(() -> new RuntimeException("Cannot find client 'moped-client'"))
.getAuthorizationSettings().getPolicies()
.size();
assertThat(createdPoliciesCount, is(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,18 @@
]
}
],
"policies": [],
"policies": [
{
"name": "Policy A",
"description": "Test Policy for testing purpose",
"type": "user",
"logic": "POSITIVE",
"decisionStrategy": "UNANIMOUS",
"config": {
"users": "[\"moped.user\"]"
}
}
],
"scopes": [
{
"name": "urn:servlet-authz:protected:admin:access"
Expand Down

0 comments on commit dcb6b46

Please sign in to comment.