Skip to content

Commit

Permalink
Fix logic in finding the effective user name (Issue #337)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesse-gallagher committed Aug 22, 2022
1 parent e7d385d commit 25ec80b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public class JNADominoClient implements IGCDominoClient<JNADominoClientAllocatio
@Override
public String getEffectiveUserName() {
if (m_effectiveUserName == null) {
if (m_builderIsAsId || StringUtil.isEmpty(m_builderUserName)) {
if (m_builderIsAsId) {
m_effectiveUserName = getIDUserName();
} else if (!StringUtil.isEmpty(m_builderUserName)) {
m_effectiveUserName = NotesNamingUtils.toCanonicalName(m_builderUserName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -77,6 +78,28 @@ public void testArbitraryUsername() throws Exception {

}

@Test
public void testArbitraryUsernameList() throws Exception {
final DominoClient client = this.getClient();

final String expected = "CN=Foo Bar/O=Baz";
try (DominoClient fooClient = DominoClientBuilder.newDominoClient()
.asUser(Arrays.asList(expected))
.build()) {

Assertions.assertEquals(expected, fooClient.getEffectiveUserName());
Assertions.assertNotEquals(expected, fooClient.getIDUserName());
Assertions.assertEquals(client.getIDUserName(), fooClient.getIDUserName());
Assertions.assertNotEquals(client.getEffectiveUserName(), fooClient.getEffectiveUserName());
this.withTempDb(fooClient, db -> {
final Optional<UserNamesList> namesList = db.getNamesList();
Assertions.assertTrue(namesList.isPresent());
Assertions.assertEquals(expected, namesList.get().getPrimaryName());
});
}

}

@Test
public void testBaseUsernameEquality() {
final DominoClient client = this.getClient();
Expand Down

0 comments on commit 25ec80b

Please # to comment.