From efc130acece3eae54b7e5897be1d5d7fd349bfc7 Mon Sep 17 00:00:00 2001 From: Vijay Date: Mon, 7 May 2018 15:28:06 +0530 Subject: [PATCH] created user with admin previlages(#1240) --- .../core/security/InitSecurityService.groovy | 21 +++++++++++-------- .../core/security/MetadataRolesUtils.groovy | 2 +- .../CheckDataModelPolicyTagSpec.groovy | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ModelCatalogueCorePluginTestApp/grails-app/services/org/modelcatalogue/core/security/InitSecurityService.groovy b/ModelCatalogueCorePluginTestApp/grails-app/services/org/modelcatalogue/core/security/InitSecurityService.groovy index 4456d27f4a..943f7e4fcd 100644 --- a/ModelCatalogueCorePluginTestApp/grails-app/services/org/modelcatalogue/core/security/InitSecurityService.groovy +++ b/ModelCatalogueCorePluginTestApp/grails-app/services/org/modelcatalogue/core/security/InitSecurityService.groovy @@ -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() @@ -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, @@ -82,8 +84,9 @@ class InitSecurityService { for ( Map m : [ [username: 'supervisor', authority: MetadataRoles.ROLE_SUPERVISOR], [username: 'curator', authority: MetadataRoles.ROLE_CURATOR], - [username: 'user', authority: MetadataRoles.ROLE_USER],] as List< Map >) { - userRoleGormService.saveUserRoleByUsernameAndAuthority(m.username , m.authority) + [username: 'user', authority: MetadataRoles.ROLE_USER], + [username: 'admin', authority: MetadataRoles.ROLE_ADMIN],] as List>) { + userRoleGormService.saveUserRoleByUsernameAndAuthority(m.username, m.authority) } } } diff --git a/ModelCatalogueCorePluginTestApp/src/groovy/org/modelcatalogue/core/security/MetadataRolesUtils.groovy b/ModelCatalogueCorePluginTestApp/src/groovy/org/modelcatalogue/core/security/MetadataRolesUtils.groovy index 5a73bf9e95..ee74a981b2 100644 --- a/ModelCatalogueCorePluginTestApp/src/groovy/org/modelcatalogue/core/security/MetadataRolesUtils.groovy +++ b/ModelCatalogueCorePluginTestApp/src/groovy/org/modelcatalogue/core/security/MetadataRolesUtils.groovy @@ -7,7 +7,7 @@ import static org.modelcatalogue.core.security.MetadataRoles.* class MetadataRolesUtils { static List findAll() { - [ROLE_USER, ROLE_CURATOR, ROLE_SUPERVISOR] + [ROLE_USER, ROLE_CURATOR, ROLE_SUPERVISOR, ROLE_ADMIN] } static List getRolesForDataModelAdministrationPermission() { diff --git a/ModelCatalogueCorePluginTestApp/test/functional/org/modelcatalogue/core/datamodel/CheckDataModelPolicyTagSpec.groovy b/ModelCatalogueCorePluginTestApp/test/functional/org/modelcatalogue/core/datamodel/CheckDataModelPolicyTagSpec.groovy index 06153e4065..433ea04840 100644 --- a/ModelCatalogueCorePluginTestApp/test/functional/org/modelcatalogue/core/datamodel/CheckDataModelPolicyTagSpec.groovy +++ b/ModelCatalogueCorePluginTestApp/test/functional/org/modelcatalogue/core/datamodel/CheckDataModelPolicyTagSpec.groovy @@ -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 }