Skip to content

Commit

Permalink
created user with admin previlages(#1240)
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayshukla30 committed May 7, 2018
1 parent 722df7c commit efc130a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ class InitSecurityService {
void initRoleHierarchyEntry() {
boolean reload = false
for ( String entry : [
"${MetadataRoles.ROLE_SUPERVISOR} > ${MetadataRoles.ROLE_CURATOR}".toString(),
"${MetadataRoles.ROLE_CURATOR} > ${MetadataRoles.ROLE_USER}".toString(),
]) {
if ( !roleHierarchyEntryGormService.findByEntry(entry) ) {
roleHierarchyEntryGormService.save(entry)
reload = true
}
"${MetadataRoles.ROLE_ADMIN} > ${MetadataRoles.ROLE_SUPERVISOR}".toString(),
"${MetadataRoles.ROLE_SUPERVISOR} > ${MetadataRoles.ROLE_CURATOR}".toString(),
"${MetadataRoles.ROLE_CURATOR} > ${MetadataRoles.ROLE_USER}".toString(),
]) {
if ( !roleHierarchyEntryGormService.findByEntry(entry) ) {
roleHierarchyEntryGormService.save(entry)
reload = true
}
}
if ( reload ) {
springSecurityService.reloadDBRoleHierarchy()
Expand All @@ -64,6 +65,7 @@ class InitSecurityService {
[username: 'supervisor', password: System.getenv('MC_SUPERVISOR_PASSWORD') ?: 'supervisor', email: System.getenv(UserService.ENV_SUPERVISOR_EMAIL), apiKey: 'supervisorabcdef123456'],
[username: 'user', password: 'user', apiKey: 'viewerabcdef123456'],
[username: 'curator', password: 'curator', apiKey: 'curatorabcdef123456'],
[username: 'admin', password: 'admin', apiKey: 'adminabcdef123456'],
] ) {
if ( !userGormService.findByUsername(m.username as String) ) {
User user = new User(name: m.username,
Expand All @@ -82,8 +84,9 @@ class InitSecurityService {
for ( Map<String, String> m : [
[username: 'supervisor', authority: MetadataRoles.ROLE_SUPERVISOR],
[username: 'curator', authority: MetadataRoles.ROLE_CURATOR],
[username: 'user', authority: MetadataRoles.ROLE_USER],] as List< Map<String, String> >) {
userRoleGormService.saveUserRoleByUsernameAndAuthority(m.username , m.authority)
[username: 'user', authority: MetadataRoles.ROLE_USER],
[username: 'admin', authority: MetadataRoles.ROLE_ADMIN],] as List<Map<String, String>>) {
userRoleGormService.saveUserRoleByUsernameAndAuthority(m.username, m.authority)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import static org.modelcatalogue.core.security.MetadataRoles.*
class MetadataRolesUtils {

static List<String> findAll() {
[ROLE_USER, ROLE_CURATOR, ROLE_SUPERVISOR]
[ROLE_USER, ROLE_CURATOR, ROLE_SUPERVISOR, ROLE_ADMIN]
}

static List<String> getRolesForDataModelAdministrationPermission() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CheckDataModelPolicyTagSpec extends GebSpec {
def "Login as admin"() {
when:
LoginPage loginPage = to LoginPage
loginPage.login("supervisor", "supervisor")
loginPage.login("admin", "admin")
then:
at DashboardPage
}
Expand Down

0 comments on commit efc130a

Please sign in to comment.