-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
166 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,10 @@ | |
*/ | ||
package org.opendevstack.provision.config; | ||
|
||
import static java.util.Map.entry; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import java.util.Map; | ||
import org.opendevstack.provision.adapter.IODSAuthnzAdapter; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
|
@@ -21,43 +25,37 @@ | |
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
|
||
import java.util.Map; | ||
|
||
import static java.util.Map.entry; | ||
import static org.mockito.Mockito.mock; | ||
|
||
@Configuration | ||
public class AuthSecurityTestConfig { | ||
|
||
public static final String TEST_USER_USERNAME = "user"; | ||
public static final String TEST_ADMIN_USERNAME = "admin"; | ||
public static final String TEST_ADMIN_EMAIL = "[email protected]"; | ||
public static final String TEST_NOT_PERMISSIONED_USER_USERNAME = "not-permissioned-user"; | ||
public static final String TEST_VALID_CREDENTIAL = "validsecret"; | ||
|
||
@Value("${idmanager.group.opendevstack-users}") | ||
protected String roleUser; | ||
|
||
@Value("${idmanager.group.opendevstack-administrators}") | ||
protected String roleAdmin; | ||
|
||
@Bean | ||
public PasswordEncoder passwordEncoder() { | ||
return new BCryptPasswordEncoder(); | ||
} | ||
|
||
@Bean(name = "testUsersAndRoles") | ||
public Map<String, String> testUsersAndRoles() { | ||
return Map.ofEntries( | ||
entry(TEST_USER_USERNAME, roleUser), | ||
entry(TEST_ADMIN_USERNAME, roleAdmin), | ||
entry(TEST_NOT_PERMISSIONED_USER_USERNAME, "not-opendevstack-user")); | ||
} | ||
|
||
@Bean | ||
@Primary | ||
public IODSAuthnzAdapter iodsAuthnzAdapter() { | ||
return mock(IODSAuthnzAdapter.class); | ||
} | ||
|
||
public static final String TEST_USER_USERNAME = "user"; | ||
public static final String TEST_ADMIN_USERNAME = "admin"; | ||
public static final String TEST_ADMIN_EMAIL = "[email protected]"; | ||
public static final String TEST_NOT_PERMISSIONED_USER_USERNAME = "not-permissioned-user"; | ||
public static final String TEST_VALID_CREDENTIAL = "validsecret"; | ||
|
||
@Value("${idmanager.group.opendevstack-users}") | ||
protected String roleUser; | ||
|
||
@Value("${idmanager.group.opendevstack-administrators}") | ||
protected String roleAdmin; | ||
|
||
@Bean | ||
public PasswordEncoder passwordEncoder() { | ||
return new BCryptPasswordEncoder(); | ||
} | ||
|
||
@Bean(name = "testUsersAndRoles") | ||
public Map<String, String> testUsersAndRoles() { | ||
return Map.ofEntries( | ||
entry(TEST_USER_USERNAME, roleUser), | ||
entry(TEST_ADMIN_USERNAME, roleAdmin), | ||
entry(TEST_NOT_PERMISSIONED_USER_USERNAME, "not-opendevstack-user")); | ||
} | ||
|
||
@Bean | ||
@Primary | ||
public IODSAuthnzAdapter iodsAuthnzAdapter() { | ||
return mock(IODSAuthnzAdapter.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters