Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Created a few tests for tech user creation regarding subject

Signed-off-by: Menahem Julien Raccah Lisei <[email protected]>
  • Loading branch information
menajrl committed Jan 9, 2020
1 parent de5d3db commit c523071
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,33 @@ public void testCreateTechnicalUserAndAddToNonExistingNamespace() {
public void testCreateTechnicalUserWithoutAuthenticationProvider() {
// this implicitly creates the "playground" namespace
User user = setupUserWithRoles("alex");
accountService.createTechnicalUserAndAddToTenant("playground", "pepe", null, Role.USER);
accountService.createTechnicalUserAndAddToTenant(
"playground", "pepe", new TenantTechnicalUserDto().setSubject("subject").setAuthenticationProviderId(null), Role.USER
);
}

@Test(expected = IllegalArgumentException.class)
public void testCreateTechnicalUserWithoutSubject() {
User user = setupUserWithRoles("alex");
accountService.createTechnicalUserAndAddToTenant(
"playground", "pepe", new TenantTechnicalUserDto().setSubject(null).setAuthenticationProviderId("GITHUB"), Role.USER
);
}

@Test(expected = IllegalArgumentException.class)
public void testCreateTechnicalUserWithSubjectTooShort() {
User user = setupUserWithRoles("alex");
accountService.createTechnicalUserAndAddToTenant(
"playground", "pepe", new TenantTechnicalUserDto().setSubject("abc").setAuthenticationProviderId("GITHUB"), Role.USER
);
}

@Test(expected = IllegalArgumentException.class)
public void testCreateTechnicalUserWithSubjectNotAlphanumeric() {
User user = setupUserWithRoles("alex");
accountService.createTechnicalUserAndAddToTenant(
"playground", "pepe", new TenantTechnicalUserDto().setSubject("!§$%").setAuthenticationProviderId("GITHUB"), Role.USER
);
}

private User setupUserWithRoles(String username) {
Expand Down

0 comments on commit c523071

Please sign in to comment.