Skip to content

Commit

Permalink
created user with admin previlages(#1239)
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayshukla30 committed May 7, 2018
1 parent ed07024 commit 8bf8a91
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class InitSecurityService {
void initRoleHierarchyEntry() {
boolean reload = false
for ( String entry : [
"${MetadataRoles.ROLE_ADMIN} > ${MetadataRoles.ROLE_SUPERVISOR}".toString(),
"${MetadataRoles.ROLE_SUPERVISOR} > ${MetadataRoles.ROLE_CURATOR}".toString(),
"${MetadataRoles.ROLE_CURATOR} > ${MetadataRoles.ROLE_USER}".toString(),
]) {
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,7 +84,8 @@ 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> >) {
[username: 'user', authority: MetadataRoles.ROLE_USER],
[username: 'admin', authority: MetadataRoles.ROLE_ADMIN],] as List< Map<String, String> >) {
userRoleGormService.saveUserRoleByUsernameAndAuthority(m.username , m.authority)
}
}
Expand Down
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 @@ -53,11 +53,15 @@ class CheckDataTypeAddedToNewVersionSpec extends GebSpec {
String dataModelVersionNote = "FINALIZING_DATAMODEL"
@Shared
String dataModelNewVersion = "0.0.3"
@Shared
String dataTypeTwoName = "TESTING_DATATYPE_TWO"
@Shared
String dataTypeTwoDescription = "TESTING_DATATYPE_TWO_DESCRIPTION"

def "Login as admin"() {
when:
LoginPage loginPage = to LoginPage
loginPage.login("curator", "curator")
loginPage.login("admin", "admin")
then:
at DashboardPage
}
Expand Down Expand Up @@ -142,7 +146,7 @@ class CheckDataTypeAddedToNewVersionSpec extends GebSpec {
DataModelPage dataModelPage = browser.page DataModelPage
then:
true
//has to be done from activity tab
dataModelPage.isDataModelFinalized()
}

def "create new version"() {
Expand Down Expand Up @@ -177,12 +181,42 @@ class CheckDataTypeAddedToNewVersionSpec extends GebSpec {
DataModelPage dataModelPage = browser.page DataModelPage
dataModelPage.treeView.versions()
then:
at DataModelPage
at VersionsPage

when:
dataModelPage = browser.page DataModelPage
dataModelPage.selectModelByVersion(dataModelNewVersion)
VersionsPage versionsPage = browser.page VersionsPage
driver.navigate().refresh()
versionsPage.selectModelByVersion(dataModelNewVersion)
then:
at DataModelPage
}

def "create new data type"() {
when:
DataModelPage dataModelPage = browser.page DataModelPage
dataModelPage.treeView.dataTypes()
then:
at DataTypesPage

when:
DataTypesPage dataTypesPage = browser.page DataTypesPage
dataTypesPage.createDataTypeFromGreenPlusButton()
then:
at CreateDataTypePage

when:
CreateDataTypePage createDataTypePage = browser.page CreateDataTypePage
createDataTypePage.name = dataTypeTwoName
createDataTypePage.description = dataTypeTwoDescription
createDataTypePage.buttons.save()
then:
at DataTypesPage
}

def "verify new data type is created"() {
when:
DataTypesPage dataTypesPage = browser.page DataTypesPage
then:
dataTypesPage.hasDataType(dataTypeTwoName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreatedDataModelNewVersionPage extends Page implements InputUtils {

void hide() {
hideButton.click()
sleep(2000)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class DataModelPage extends Page {
exportXMLLink(required: false) { $('a#catalogue-element-export-specific-reports_12-menu-item-link') }
finalizedLink(required: false) { $("a#finalize-menu-item-link") }
rows { $('div.inf-table-body table tbody tr td') }
activityList {
$("#activity-changes>div.inf-table-body>table>tbody>tr")
}
}

String getRowsText() {
Expand Down Expand Up @@ -75,7 +78,7 @@ class DataModelPage extends Page {
rightSideTitleH3.text()
}

void selectModelByVersion(String version) {
rows.$('a', text: version).click()
boolean isDataModelFinalized() {
activityList.$('td:nth-child(4) span span')*.text().join(",").contains("finalized")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ class DataTypesPage extends Page {
void createDataTypeFromGreenPlusButton() {
addItemIcon.click()
}

boolean hasDataType(String name) {
rows.$('a', text: name).displayed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ class VersionsPage extends Page {
rows { $('#history-tab tbody tr') }
}

boolean rowsContainText(String text) {
for ( int i = 0; i < rows.size(); i++ ) {
if ( rows[i].text().contains(text) ) {
boolean rowsContainText(String text) {
for (int i = 0; i < rows.size(); i++) {
if (rows[i].text().contains(text)) {
return true
}
}
false
}

void selectModelByVersion(String version) {
rows.$('td a', text: version).click()
}

}

0 comments on commit 8bf8a91

Please sign in to comment.