KEYCLOAK-8664 KEYCLOAK-8665 KEYCLOAK-8666 fix assertions in testsuite
This commit is contained in:
parent
f449b8b454
commit
4d2300f17e
3 changed files with 13 additions and 3 deletions
|
@ -36,7 +36,10 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,4 +148,11 @@ public class Assert extends org.junit.Assert {
|
||||||
org.junit.Assert.assertThat(actual, allOf(greaterThanOrEqualTo(expected - 50), lessThanOrEqualTo(expected)));
|
org.junit.Assert.assertThat(actual, allOf(greaterThanOrEqualTo(expected - 50), lessThanOrEqualTo(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void assertRoleAttributes(Map<String, List<String>> expected, Map<String, List<String>> actual) {
|
||||||
|
assertThat(actual.keySet(), equalTo(expected.keySet()));
|
||||||
|
for (String expectedKey : expected.keySet()) {
|
||||||
|
assertThat(actual.get(expectedKey).size(), is(equalTo(expected.get(expectedKey).size())));
|
||||||
|
assertThat(actual.get(expectedKey), containsInAnyOrder(expected.get(expectedKey).toArray()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ public class RoleByIdResourceTest extends AbstractAdminTest {
|
||||||
Map<String, List<String>> roleAttributes = role.getAttributes();
|
Map<String, List<String>> roleAttributes = role.getAttributes();
|
||||||
assertNotNull(roleAttributes);
|
assertNotNull(roleAttributes);
|
||||||
|
|
||||||
assertEquals(attributes, roleAttributes);
|
Assert.assertRoleAttributes(attributes, roleAttributes);
|
||||||
|
|
||||||
|
|
||||||
// delete an attribute
|
// delete an attribute
|
||||||
|
@ -188,7 +188,7 @@ public class RoleByIdResourceTest extends AbstractAdminTest {
|
||||||
roleAttributes = role.getAttributes();
|
roleAttributes = role.getAttributes();
|
||||||
assertNotNull(roleAttributes);
|
assertNotNull(roleAttributes);
|
||||||
|
|
||||||
assertEquals(attributes, roleAttributes);
|
Assert.assertRoleAttributes(attributes, roleAttributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,7 +311,7 @@ public class ExportImportTest extends AbstractKeycloakTest {
|
||||||
assertEquals(sampleRealmRoleId, importedSampleRealmRoleId);
|
assertEquals(sampleRealmRoleId, importedSampleRealmRoleId);
|
||||||
|
|
||||||
Map<String, List<String>> importedRoleAttributes = adminClient.realm("test").roles().get("attribute-role").toRepresentation().getAttributes();
|
Map<String, List<String>> importedRoleAttributes = adminClient.realm("test").roles().get("attribute-role").toRepresentation().getAttributes();
|
||||||
assertEquals(roleAttributes, importedRoleAttributes);
|
Assert.assertRoleAttributes(roleAttributes, importedRoleAttributes);
|
||||||
|
|
||||||
String importedSampleClientRoleId = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getId();
|
String importedSampleClientRoleId = adminClient.realm("test").clients().get(testAppId).roles().get("sample-client-role").toRepresentation().getId();
|
||||||
assertEquals(sampleClientRoleId, importedSampleClientRoleId);
|
assertEquals(sampleClientRoleId, importedSampleClientRoleId);
|
||||||
|
|
Loading…
Reference in a new issue