graphdb-workbench-tests 2.0.1 → 2.0.2-TR1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,12 @@
1
1
  describe('User and Access', () => {
2
2
 
3
- let repositoryId;
4
3
  const PASSWORD = "password";
5
4
  const ROLE_USER = "#roleUser";
6
5
  const ROLE_REPO_MANAGER = "#roleRepoAdmin";
7
6
  const ROLE_CUSTOM_ADMIN = "#roleAdmin";
8
7
  const DEFAULT_ADMIN_PASSWORD = "root";
9
8
 
10
- before(() => {
11
- repositoryId = 'setup-repo' + Date.now();
12
- cy.createRepository({id: repositoryId});
13
- });
14
-
15
9
  beforeEach(() => {
16
- cy.presetRepository(repositoryId);
17
-
18
10
  cy.visit('/users');
19
11
  cy.window();
20
12
  // Users table should be visible
@@ -33,7 +25,6 @@ describe('User and Access', () => {
33
25
  }
34
26
  });
35
27
  });
36
- cy.deleteRepository(repositoryId);
37
28
  });
38
29
 
39
30
  it('Initial state', () => {
@@ -60,58 +51,54 @@ describe('User and Access', () => {
60
51
  cy.get('@user').find('.date-created').should('be.visible');
61
52
  });
62
53
 
63
- it('Create users of each type', () => {
54
+ it('Create user', () => {
55
+ const name = "user";
64
56
  //create a normal read/write user
65
- createUser("user", PASSWORD, ROLE_USER);
57
+ createUser(name, PASSWORD, ROLE_USER);
58
+ testForUser(name, false);
59
+ });
60
+
61
+ it('Create repo-manager', () => {
62
+ const name = "repo-manager";
63
+ //create a repo-manager
64
+ createUser(name, PASSWORD, ROLE_REPO_MANAGER);
65
+ testForUser(name, false);
66
+ });
67
+
68
+ it('Create second admin', () => {
69
+ const name = "second-admin";
70
+ //create a custom admin
71
+ createUser(name, PASSWORD, ROLE_CUSTOM_ADMIN);
72
+ testForUser(name, true);
73
+ });
74
+
75
+ function testForUser(name, isAdmin) {
66
76
  //enable security
67
77
  getToggleSecuritySwitch().click();
68
- //login with the user
69
- loginWithUser("user", PASSWORD);
70
- cy.url().should('include', '/users');
71
- //verify permissions
72
- cy.get('.alert-danger').should('contain', 'You have no permission to access this functionality with your current credentials.');
73
- logout();
74
- //login with admin
75
- loginWithUser("admin", DEFAULT_ADMIN_PASSWORD);
76
- cy.get('.ot-splash').should('not.be.visible');
77
- getUsersTable().should('be.visible');
78
- //delete user
79
- deleteUser("user");
80
- //create repository manager
81
- createUser("repo-manager", PASSWORD, ROLE_REPO_MANAGER);
82
- logout();
83
- //login with the repository manager
84
- loginWithUser("repo-manager", PASSWORD);
78
+ //login new user
79
+ loginWithUser(name, PASSWORD);
85
80
  //verify permissions
86
81
  cy.url().should('include', '/users');
87
- cy.get('.alert-danger').should('contain', 'You have no permission to access this functionality with your current credentials.');
82
+ if (isAdmin) {
83
+ getUsersTable().should('be.visible');
84
+ } else {
85
+ cy.get('.alert-danger').should('contain',
86
+ 'You have no permission to access this functionality with your current credentials.');
87
+ }
88
88
  logout();
89
89
  //login with the admin
90
90
  loginWithUser("admin", DEFAULT_ADMIN_PASSWORD);
91
91
  cy.get('.ot-splash').should('not.be.visible');
92
92
  getUsersTable().should('be.visible');
93
- //delete repository manager
94
- deleteUser("repo-manager")
95
- .then(() => {
96
- //create a custom admin
97
- createUser("second-admin", PASSWORD, ROLE_CUSTOM_ADMIN);
98
- logout();
99
- //login with custom admin
100
- loginWithUser("second-admin", PASSWORD);
101
- cy.url().should('include', '/users');
102
- logout();
103
- //login with admin
104
- loginWithUser("admin", DEFAULT_ADMIN_PASSWORD);
105
- cy.get('.ot-splash').should('not.be.visible');
106
- getUsersTable().should('be.visible');
107
- //delete custom admin
108
- deleteUser("second-admin")
109
- .then(() => {
110
- //disable security
111
- getToggleSecuritySwitch().click();
112
- });
113
- });
114
- });
93
+ //delete new-user
94
+ deleteUser(name);
95
+ //disable security
96
+ getToggleSecuritySwitch().click({force: true});
97
+ cy.get('#toggle-security').find('.security-switch-label').should('be.visible')
98
+ .and('contain', 'Security is OFF');
99
+ getUsersTable().should('be.visible');
100
+ }
101
+
115
102
  it('Warn users when setting no password when creating new user admin', () => {
116
103
  getUsersTable().should('be.visible');
117
104
  createUser("adminWithNoPassword", PASSWORD, ROLE_CUSTOM_ADMIN);
@@ -201,7 +188,7 @@ describe('User and Access', () => {
201
188
  });
202
189
  return cy.waitUntil(() =>
203
190
  cy.get('@deleteBtn')
204
- .then(deleteBtn => deleteBtn && Cypress.dom.isAttached(deleteBtn) && deleteBtn.trigger('click')))
191
+ .then((deleteBtn) => deleteBtn && Cypress.dom.isAttached(deleteBtn) && deleteBtn.trigger('click')))
205
192
  .then(() => {
206
193
  cy.get('.confirm-btn').click();
207
194
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "2.0.1",
3
+ "version": "2.0.2-TR1",
4
4
  "description": "Cypress tests for GraphDB workbench",
5
5
  "scripts": {
6
6
  "start": "cypress open",
@@ -9,12 +9,10 @@ Cypress.Commands.add('setDefaultUserData', () => {
9
9
  cy.request({
10
10
  method: 'PATCH',
11
11
  url: `rest/security/users/${encodeURIComponent('admin')}`,
12
- headers: {
13
- 'X-GraphDB-Password': 'root'
14
- },
15
12
  body: {
16
13
  data: {
17
- appSettings: defaultUserSettings
14
+ "appSettings": defaultUserSettings,
15
+ 'password': 'root'
18
16
  }
19
17
  }
20
18
  }).then((response) => {