Skip to content

Commit

Permalink
[ELY-2696] Update 3 tests in PrincipalMappingSuiteChild to call a com…
Browse files Browse the repository at this point in the history
…mon method in order to remove duplicated code
  • Loading branch information
map-b committed Oct 17, 2023
1 parent ba17f4c commit 89dbbd1
Showing 1 changed file with 8 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
*/
public class PrincipalMappingSuiteChild {

@Test
public void testSimpleToDn() throws RealmUnavailableException {
private void testSimpleCommon() throws RealmUnavailableException {
SecurityRealm realm = LdapSecurityRealmBuilder.builder()
.setDirContextSupplier(LdapTestSuite.dirContextFactory.create())
.identityMapping()
Expand All @@ -52,6 +51,11 @@ public void testSimpleToDn() throws RealmUnavailableException {
assertFalse("Exists", identity.exists());
}

@Test
public void testSimpleToDn() throws RealmUnavailableException {
testSimpleCommon();
}

@Test
public void testDnToSimple() throws RealmUnavailableException {
SecurityRealm realm = LdapSecurityRealmBuilder.builder()
Expand All @@ -70,36 +74,12 @@ public void testDnToSimple() throws RealmUnavailableException {

@Test
public void testSimpleToSimpleValidate() throws RealmUnavailableException {
SecurityRealm realm = LdapSecurityRealmBuilder.builder()
.setDirContextSupplier(LdapTestSuite.dirContextFactory.create())
.identityMapping()
.setSearchDn("dc=elytron,dc=wildfly,dc=org")
.setRdnIdentifier("uid")
.build()
.build();

RealmIdentity identity = realm.getRealmIdentity(new NamePrincipal("PlainUser"));
assertTrue("Exists", identity.exists());

identity = realm.getRealmIdentity(new NamePrincipal("nobody"));
assertFalse("Exists", identity.exists());
testSimpleCommon();
}

@Test
public void testSimpleToSimpleReload() throws RealmUnavailableException {
SecurityRealm realm = LdapSecurityRealmBuilder.builder()
.setDirContextSupplier(LdapTestSuite.dirContextFactory.create())
.identityMapping()
.setSearchDn("dc=elytron,dc=wildfly,dc=org")
.setRdnIdentifier("uid")
.build()
.build();

RealmIdentity identity = realm.getRealmIdentity(new NamePrincipal("PlainUser"));
assertTrue("Exists", identity.exists());

identity = realm.getRealmIdentity(new NamePrincipal("nobody"));
assertFalse("Exists", identity.exists());
testSimpleCommon();
}

@Test
Expand Down

0 comments on commit 89dbbd1

Please sign in to comment.