create scmadmin also if only _anonymous user exists

This commit is contained in:
Eduard Heimbuch
2019-11-20 11:42:32 +01:00
parent 6ac0ba3ab9
commit 906c27ebba
2 changed files with 20 additions and 4 deletions

View File

@@ -70,7 +70,19 @@ class SetupContextListenerTest {
}
@Test
void shouldCreateAdminAccountAndAssignPermissions() {
void shouldCreateAdminAccountIfNoUserExistsAndAssignPermissions() {
when(passwordService.encryptPassword("scmadmin")).thenReturn("secret");
setupContextListener.contextInitialized(null);
verifyAdminCreated();
verifyAdminPermissionsAssigned();
}
@Test
void shouldCreateAdminAccountIfOnlyAnonymousUserExistsAndAssignPermissions() {
when(userManager.getAll()).thenReturn(Lists.newArrayList(SCMContext.ANONYMOUS));
when(userManager.contains(SCMContext.USER_ANONYMOUS)).thenReturn(true);
when(passwordService.encryptPassword("scmadmin")).thenReturn("secret");
setupContextListener.contextInitialized(null);