graphdb-workbench-tests 2.8.4 → 3.0.0-NEW-JENKINS-1

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.
Files changed (76) hide show
  1. package/fixtures/graph/rdf.txt +130 -0
  2. package/fixtures/graphdb-import/ontology-and-shapes.ttl +562 -0
  3. package/fixtures/graphdb-import/swapi-dataset.ttl +4393 -0
  4. package/fixtures/graphql/endpoints/graphql-endpoints-info.json +49 -0
  5. package/fixtures/graphql/endpoints/no-graphql-endpoints-info.json +3 -0
  6. package/fixtures/graphql/soml/big-swapi-schema-broken.yaml +83167 -0
  7. package/fixtures/graphql/soml/swapi-schema-broken.yaml +880 -0
  8. package/fixtures/graphql/soml/swapi-schema-broken.zip +0 -0
  9. package/fixtures/graphql/soml/swapi-schema-film-restricted.yaml +335 -0
  10. package/fixtures/graphql/soml/swapi-schema-planets.yaml +51 -0
  11. package/fixtures/graphql/soml/swapi-schema-species.yaml +66 -0
  12. package/fixtures/graphql/soml/swapi-schema.yaml +857 -0
  13. package/fixtures/graphql/soml/swapi-schemas.zip +0 -0
  14. package/fixtures/locale-en.json +666 -37
  15. package/fixtures/ttyg/agent/get-agent-list-autocomplete-query.json +23 -0
  16. package/fixtures/ttyg/autocomplete-response.json +154 -0
  17. package/integration/explore/class.hierarchy.spec.js +131 -184
  18. package/integration/explore/graphs.overview.spec.js +18 -10
  19. package/integration/explore/visual-graph/graphs-config.spec.js +17 -1
  20. package/integration/explore/visual-graph/visual-graph-node-labels.spec.js +68 -0
  21. package/integration/graphql/activate-deactivate-graphql-endpoint.spec.js +40 -0
  22. package/integration/graphql/create-graphql-endpoint.spec.js +281 -0
  23. package/integration/graphql/delete-graphql-endpoint.spec.js +46 -0
  24. package/integration/graphql/edit-graphql-enpoint.spec.js +160 -0
  25. package/integration/graphql/export-graphql-endpoint-definition.spec.js +35 -0
  26. package/integration/graphql/filter-graphql-endpoints-on-management-view.spec.js +66 -0
  27. package/integration/graphql/graphql-endpoint-management-view.spec.js +142 -0
  28. package/integration/graphql/graphql-playground.spec.js +110 -0
  29. package/integration/graphql/import-graphql-endpoint-definitions.spec.js +269 -0
  30. package/integration/graphql/set-default-graphql-endpoint.spec.js +42 -0
  31. package/integration/import/import-server-files-batch-operations.spec.js +4 -3
  32. package/integration/import/import-server-files.spec.js +29 -7
  33. package/integration/import/import-user-data-url.spec.js +33 -0
  34. package/integration/import/import-view.spec.js +2 -1
  35. package/integration/repository/repositories.spec.js +9 -4
  36. package/integration/setup/user-and-access.spec.js +695 -117
  37. package/integration/sparql-editor/actions/show-saved-queries.spec.js +1 -1
  38. package/integration/sparql-editor/saved-query/readonly-query.spec.js +66 -0
  39. package/integration/ttyg/edit-agent.spec.js +45 -0
  40. package/integration-flaky/setup/users-and-access/security-and-free-access.spec.js +54 -0
  41. package/{integration → integration-flaky}/ttyg/ttyg-permission.spec.js +4 -3
  42. package/npm-shrinkwrap.json +931 -305
  43. package/package.json +3 -3
  44. package/steps/class-views-steps.js +139 -0
  45. package/steps/explore/graphs-overview-steps.js +12 -0
  46. package/steps/graphql/create-graphql-endpoint-steps.js +277 -0
  47. package/steps/graphql/edit-graphql-endpoint-steps.js +124 -0
  48. package/steps/graphql/generation-report-modal-steps.js +34 -0
  49. package/steps/graphql/graphiql-editor-tools-steps.js +10 -0
  50. package/steps/graphql/graphiql-playground-steps.js +6 -0
  51. package/steps/graphql/graphql-endpoint-management-steps.js +147 -0
  52. package/steps/graphql/graphql-playground-steps.js +90 -0
  53. package/steps/graphql/import-endpoint-definition-modal-steps.js +80 -0
  54. package/steps/home-steps.js +1 -1
  55. package/steps/import/import-settings-dialog-steps.js +12 -0
  56. package/steps/import/import-steps.js +9 -4
  57. package/steps/import/import-test-constants.js +1 -0
  58. package/steps/import/import-user-data-steps.js +8 -0
  59. package/steps/login-steps.js +20 -0
  60. package/steps/modal-dialog-steps.js +8 -0
  61. package/steps/repository-steps.js +4 -0
  62. package/steps/setup/user-and-access-steps.js +165 -11
  63. package/steps/ttyg/ttyg-agent-settings-modal.steps.js +44 -0
  64. package/steps/visual-graph-steps.js +14 -0
  65. package/steps/yasgui/saved-queries-dialog.js +19 -3
  66. package/stubs/global-operations-statuses-stub.js +2 -2
  67. package/stubs/graphql/graphql-stubs.js +146 -0
  68. package/stubs/repositories/repositories-stubs.js +4 -0
  69. package/stubs/ttyg/ttyg-stubs.js +7 -0
  70. package/stubs/yasgui/query-stubs.js +2 -2
  71. package/support/import-commands.js +28 -0
  72. package/support/repository-commands.js +10 -3
  73. package/support/security-command.js +49 -8
  74. package/support/user-commands.js +10 -2
  75. package/utils/html-util.js +21 -0
  76. /package/fixtures/{graphql-editor → queries}/default-query-response.json +0 -0
@@ -1,4 +1,11 @@
1
1
  import {UserAndAccessSteps} from "../../steps/setup/user-and-access-steps";
2
+ import {RepositoriesStubs} from "../../stubs/repositories/repositories-stubs";
3
+ import {RepositorySelectorSteps} from "../../steps/repository-selector-steps";
4
+ import {ModalDialogSteps} from "../../steps/modal-dialog-steps";
5
+ import {ToasterSteps} from "../../steps/toaster-steps";
6
+ import HomeSteps from "../../steps/home-steps";
7
+ import {LoginSteps} from "../../steps/login-steps";
8
+
2
9
 
3
10
  describe('User and Access', () => {
4
11
 
@@ -8,132 +15,348 @@ describe('User and Access', () => {
8
15
  const ROLE_CUSTOM_ADMIN = "#roleAdmin";
9
16
  const DEFAULT_ADMIN_PASSWORD = "root";
10
17
 
11
- beforeEach(() => {
12
- UserAndAccessSteps.visit();
13
- cy.window();
14
- // Users table should be visible
15
- UserAndAccessSteps.getUsersTable().should('be.visible');
16
- });
18
+ context('', () => {
19
+ const user = "user";
20
+
21
+ beforeEach(() => {
22
+ UserAndAccessSteps.visit();
23
+ cy.window();
24
+ // Users table should be visible
25
+ UserAndAccessSteps.getUsersTable().should('be.visible');
26
+ });
27
+
28
+ afterEach(() => {
29
+ cy.loginAsAdmin().then(()=> {
30
+ cy.deleteUser(user, true);
31
+ cy.switchOffSecurity(true);
32
+ });
33
+ });
34
+
35
+ it('Initial state', () => {
36
+ // Create new user button should be visible
37
+ UserAndAccessSteps.getCreateNewUserButton().should('be.visible');
38
+ // Security should be disabled
39
+ UserAndAccessSteps.getSecuritySwitchLabel().should('be.visible').and('contain', 'Security is OFF');
40
+ UserAndAccessSteps.getSecurityCheckbox().should('not.be.checked');
41
+ // Only admin user should be created by default
42
+ UserAndAccessSteps.getTableRow().should('have.length', 1);
43
+ UserAndAccessSteps.findUserInTable('admin');
44
+ UserAndAccessSteps.getUserType().should('be.visible').and('contain', 'Administrator');
45
+ // The admin should have unrestricted rights
46
+ UserAndAccessSteps.getRepositoryRights().should('be.visible').and('contain', 'Unrestricted');
47
+ // And can be edited
48
+ UserAndAccessSteps.getEditUserButton().should('be.visible').and('not.be.disabled');
49
+ // And cannot be deleted
50
+ UserAndAccessSteps.getDeleteUserButton().should('not.exist');
51
+ // Date created should be visible
52
+ UserAndAccessSteps.getDateCreated().should('be.visible');
53
+ });
54
+
55
+ it('Create user', () => {
56
+ //create a normal read/write user
57
+ createUser(user, PASSWORD, ROLE_USER, {readWrite: true});
58
+ testForUser(user, false);
59
+ });
60
+
61
+ it('Create repo-manager', () => {
62
+ //create a repo-manager
63
+ createUser(user, PASSWORD, ROLE_REPO_MANAGER);
64
+ testForUser(user, false);
65
+ });
66
+
67
+ it('Create second admin', () => {
68
+ //create a custom admin
69
+ createUser(user, PASSWORD, ROLE_CUSTOM_ADMIN);
70
+ testForUser(user, true);
71
+ });
72
+
73
+ it('Create user with custom role', () => {
74
+ // When I create a read/write user
75
+ UserAndAccessSteps.clickCreateNewUserButton();
76
+ UserAndAccessSteps.typeUsername(user);
77
+ UserAndAccessSteps.typePassword(PASSWORD);
78
+ UserAndAccessSteps.typeConfirmPasswordField(PASSWORD);
79
+ UserAndAccessSteps.selectRoleRadioButton(ROLE_USER);
80
+ // And add a custom role of 1 letter
81
+ UserAndAccessSteps.addTextToCustomRoleField('A');
82
+ clickWriteAccessForRepo('*');
83
+
84
+ // Then the 'create' button should be disabled
85
+ UserAndAccessSteps.getConfirmUserCreateButton().should('be.disabled');
86
+ // And the field should show an error
87
+ UserAndAccessSteps.getFieldError().should('contain.text', 'Must be at least 2 symbols long');
88
+ // When I add more text to the custom role tag
89
+ UserAndAccessSteps.addTextToCustomRoleField('A{enter}');
90
+ // Then the 'create' button should be enabled
91
+ UserAndAccessSteps.getConfirmUserCreateButton().should('be.enabled');
92
+ // And the field error should not exist
93
+ UserAndAccessSteps.getFieldError().should('not.be.visible');
94
+
95
+ // When I type an invalid tag
96
+ UserAndAccessSteps.addTextToCustomRoleField('B{enter}');
97
+ // And the field shows an error
98
+ UserAndAccessSteps.getFieldError().should('contain.text', 'Must be at least 2 symbols long');
99
+ // When I delete the invalid text
100
+ UserAndAccessSteps.addTextToCustomRoleField('{backspace}');
101
+ // Then the error should not be visible
102
+ UserAndAccessSteps.getFieldError().should('not.be.visible');
103
+ });
104
+
105
+ it('Adding a role with a CUSTOM_ prefix shows a warning message', () => {
106
+ // When I create a user
107
+ UserAndAccessSteps.clickCreateNewUserButton();
108
+ // And I add a custom role tag with prefix CUSTOM_
109
+ UserAndAccessSteps.addTextToCustomRoleField('CUSTOM_USER{Enter}');
110
+ // There should be a warning text
111
+ UserAndAccessSteps.getPrefixWarning(0).should('contain', 'Custom roles should be entered without the "CUSTOM_" prefix in Workbench');
112
+ });
113
+
114
+ it('Warn users when setting no password when creating new user admin', () => {
115
+ UserAndAccessSteps.getUsersTable().should('be.visible');
116
+ createUser(user, PASSWORD, ROLE_CUSTOM_ADMIN, {noPassword: true});
117
+ UserAndAccessSteps.getUsersTable().should('be.visible');
118
+ UserAndAccessSteps.getSplashLoader().should('not.be.visible');
119
+ });
120
+ })
121
+
122
+ context('GraphQL only', () => {
123
+ let repositoryId1;
124
+ let repositoryId2;
125
+ let repositoryId3;
126
+ const graphqlUser = 'graphqlUser';
127
+
128
+ beforeEach(() => {
129
+ cy.viewport(1280, 1000);
130
+ RepositoriesStubs.spyGetRepositories();
131
+ repositoryId1 = 'user-access-repo1-' + Date.now();
132
+ repositoryId2 = 'user-access-repo2-' + Date.now();
133
+ repositoryId3 = 'user-access-repo3-' + Date.now();
134
+ cy.createRepository({id: repositoryId1});
135
+ cy.createRepository({id: repositoryId2});
136
+ cy.createRepository({id: repositoryId3});
137
+ cy.presetRepository(repositoryId1);
138
+ UserAndAccessSteps.visit();
139
+ // Users table should be visible
140
+ UserAndAccessSteps.getUsersTable().should('be.visible');
141
+ });
142
+
143
+ afterEach(() => {
144
+ cy.loginAsAdmin().then(() => {
145
+ cy.deleteRepository(repositoryId1, true);
146
+ cy.deleteRepository(repositoryId2, true);
147
+ cy.deleteRepository(repositoryId3, true);
148
+ cy.deleteUser(graphqlUser, true);
149
+ cy.switchOffSecurity(true);
150
+ });
151
+
152
+ });
153
+
154
+ it('Create user with GraphQL-only access', () => {
155
+ cy.wait('@getRepositories');
156
+ createUser(graphqlUser, PASSWORD, ROLE_USER, {read: true, graphql: true, repoName: repositoryId2});
157
+ });
17
158
 
18
- after(() => {
19
- UserAndAccessSteps.visit();
20
- UserAndAccessSteps.getUsersTable().should('be.visible');
21
- UserAndAccessSteps.getUsersTableRow().then((table) => {
22
- UserAndAccessSteps.getTableRow().each(($el, index, $list) => {
23
- UserAndAccessSteps.getUsersTable().should('be.visible');
24
- const username = $el.find('.username').text();
25
- if (username !=='admin') {
26
- UserAndAccessSteps.deleteUser(username);
159
+ it('Can create user with different auth combinations', () => {
160
+ cy.wait('@getRepositories');
161
+ // WHEN I create a user with read + GraphQL for repository #2
162
+ createUser(graphqlUser, PASSWORD, ROLE_USER, {read: true, graphql: true, repoName: repositoryId2});
163
+ // THEN the user should have read + GraphQL on that repo
164
+ assertUserAuths(graphqlUser, {repo: repositoryId2, read: true, graphql: true});
165
+ // WHEN I open the edit page for that user
166
+ UserAndAccessSteps.openEditUserPage(graphqlUser);
167
+ // THEN for repository #1, the GraphQL checkbox should be disabled initially
168
+ UserAndAccessSteps.getGraphqlAccessForRepo(repositoryId1).should('be.disabled');
169
+ // WHEN I enable "read" for repository #1
170
+ editUserAuths({repo: repositoryId1, read: true});
171
+ // THEN GraphQL for repository #1 should become enabled
172
+ UserAndAccessSteps.getGraphqlAccessForRepo(repositoryId1).should('be.enabled');
173
+ // WHEN I enable GraphQL and read
174
+ editUserAuths({repo: repositoryId1, graphql: true});
175
+ editUserAuths({repo: repositoryId1, read: true});
176
+ // THEN GraphQL should be checked and disabled
177
+ UserAndAccessSteps.getGraphqlAccessForRepo(repositoryId1).should('be.checked').and('be.disabled');
178
+ // THEN for repository #3, GraphQL should be disabled initially
179
+ UserAndAccessSteps.getGraphqlAccessForRepo(repositoryId3).should('be.disabled');
180
+ // WHEN I enable "write" for repository #3
181
+ editUserAuths({repo: repositoryId3, write: true});
182
+ // THEN GraphQL for repository #3 should become enabled
183
+ UserAndAccessSteps.getGraphqlAccessForRepo(repositoryId3).should('be.enabled');
184
+ // And I expect "read" to be checked and disabled
185
+ UserAndAccessSteps.getReadAccessForRepo(repositoryId3).should('be.checked').and('be.disabled');
186
+ // I enable GraphQL for repository #3
187
+ editUserAuths({repo: repositoryId3, graphql: true});
188
+
189
+ // WHEN I confirm the user edit
190
+ UserAndAccessSteps.confirmUserEdit();
191
+ // THEN verify the final rights:
192
+ // - repo #1 has no read/write/graphql
193
+ // - repo #2 has read + graphql
194
+ // - repo #3 has write + graphql (and read was auto-checked but disabled)
195
+ assertUserAuths(graphqlUser, {repo: repositoryId1, read: false, write: false, graphql: false});
196
+ assertUserAuths(graphqlUser, {repo: repositoryId2, read: true, write: false, graphql: true});
197
+ assertUserAuths(graphqlUser, {repo: repositoryId3, read: false, write: true, graphql: true});
198
+ });
199
+
200
+ it('Should have access to 5 pages when have graphql only rights', () => {
201
+ cy.wait('@getRepositories');
202
+ // WHEN I create a user with read + GraphQL for repository #2
203
+ createUser(graphqlUser, PASSWORD, ROLE_USER, {readWrite: true, graphql: true, repoName: repositoryId1});
204
+ //enable security
205
+ UserAndAccessSteps.toggleSecurity();
206
+ //login new user
207
+ LoginSteps.loginWithUser(graphqlUser, PASSWORD);
208
+ RepositorySelectorSteps.selectRepository(repositoryId1);
209
+
210
+ MENU_ITEMS_WITHOUT_GRAPHQL.forEach(({path, expectedUrl, checks, expectedTitle}) => {
211
+ navigateMenuPath(path, expectedUrl, expectedTitle);
212
+ if (checks) {
213
+ runChecks(checks);
27
214
  }
28
215
  });
29
216
  });
30
- });
31
217
 
32
- it('Initial state', () => {
33
- // Create new user button should be visible
34
- UserAndAccessSteps.getCreateNewUserButton().should('be.visible');
35
- // Security should be disabled
36
- UserAndAccessSteps.getSecuritySwitchLabel().should('be.visible').and('contain', 'Security is OFF');
37
- UserAndAccessSteps.getSecurityCheckbox().should('not.be.checked');
38
- // Only admin user should be created by default
39
- UserAndAccessSteps.getTableRow().should('have.length', 1);
40
- UserAndAccessSteps.findUserInTable('admin');
41
- UserAndAccessSteps.getUserType().should('be.visible').and('contain', 'Administrator');
42
- // The admin should have unrestricted rights
43
- UserAndAccessSteps.getRepositoryRights().should('be.visible').and('contain', 'Unrestricted');
44
- // And can be edited
45
- UserAndAccessSteps.getEditUserButton().should('be.visible').and('not.be.disabled');
46
- // And cannot be deleted
47
- UserAndAccessSteps.getDeleteUserButton().should('not.exist');
48
- // Date created should be visible
49
- UserAndAccessSteps.getDateCreated().should('be.visible');
50
- });
218
+ it('Should not have access endpoints management when have read graphql only rights', () => {
219
+ cy.wait('@getRepositories');
220
+ // WHEN I create a user with read + GraphQL for repository #2
221
+ createUser(graphqlUser, PASSWORD, ROLE_USER, {read: true, graphql: true, repoName: repositoryId1});
222
+ //enable security
223
+ UserAndAccessSteps.toggleSecurity();
224
+ //login new user
225
+ LoginSteps.loginWithUser(graphqlUser, PASSWORD);
226
+ RepositorySelectorSteps.selectRepository(repositoryId1);
51
227
 
52
- it('Create user', () => {
53
- const name = "user";
54
- //create a normal read/write user
55
- createUser(name, PASSWORD, ROLE_USER);
56
- testForUser(name, false);
57
- });
228
+ GRAPHQL_READ_MENU_ITEMS.forEach(({path, expectedUrl, checks, expectedTitle}) => {
229
+ navigateMenuPath(path, expectedUrl, expectedTitle);
230
+ if (checks) {
231
+ runChecks(checks);
232
+ }
233
+ });
234
+ });
58
235
 
59
- it('Create repo-manager', () => {
60
- const name = "repo-manager";
61
- //create a repo-manager
62
- createUser(name, PASSWORD, ROLE_REPO_MANAGER);
63
- testForUser(name, false);
236
+ it('Should have all access to endpoints management when have REPO_MANAGER role', () => {
237
+ cy.wait('@getRepositories');
238
+ createUser(graphqlUser, PASSWORD, ROLE_REPO_MANAGER);
239
+ //enable security
240
+ UserAndAccessSteps.toggleSecurity();
241
+ HomeSteps.visit();
242
+ //login new user
243
+ LoginSteps.loginWithUser(graphqlUser, PASSWORD);
244
+ GRAPHQL_REPO_MANAGER_MENU_ITEMS.forEach(({path, expectedUrl, checks, expectedTitle}) => {
245
+ navigateMenuPath(path, expectedUrl, expectedTitle);
246
+ if (checks) {
247
+ runChecks(checks);
248
+ }
249
+ });
250
+ });
64
251
  });
65
252
 
66
- it('Create second admin', () => {
67
- const name = "second-admin";
68
- //create a custom admin
69
- createUser(name, PASSWORD, ROLE_CUSTOM_ADMIN);
70
- testForUser(name, true);
71
- });
253
+ context('GraphQL only and Free Access', () => {
254
+ let repositoryId1;
255
+ let repositoryId2;
256
+ let repositoryId3;
257
+ const graphqlUser = 'graphqlUser';
72
258
 
73
- it('Create user with custom role', () => {
74
- const name = "user";
75
- // When I create a read/write user
76
- UserAndAccessSteps.clickCreateNewUserButton();
77
- UserAndAccessSteps.typeUsername(name);
78
- UserAndAccessSteps.typePassword(PASSWORD);
79
- UserAndAccessSteps.typeConfirmPasswordField(PASSWORD);
80
- UserAndAccessSteps.selectRoleRadioButton(ROLE_USER);
81
- // And add a custom role of 1 letter
82
- UserAndAccessSteps.addTextToCustomRoleField('A');
83
- UserAndAccessSteps.getRepositoryRightsList().contains('Any data repository').nextUntil('.write').eq(1).within(() => {
84
- UserAndAccessSteps.clickWriteAccess();
85
- });
86
-
87
- // Then the 'create' button should be disabled
88
- UserAndAccessSteps.getConfirmUserCreateButton().should('be.disabled');
89
- // And the field should show an error
90
- UserAndAccessSteps.getFieldError().should('contain.text', 'Must be at least 2 symbols long');
91
- // When I add more text to the custom role tag
92
- UserAndAccessSteps.addTextToCustomRoleField('A{enter}');
93
- // Then the 'create' button should be enabled
94
- UserAndAccessSteps.getConfirmUserCreateButton().should('be.enabled');
95
- // And the field error should not exist
96
- UserAndAccessSteps.getFieldError().should('not.be.visible');
97
-
98
- // When I type an invalid tag
99
- UserAndAccessSteps.addTextToCustomRoleField('B{enter}');
100
- // And the field shows an error
101
- UserAndAccessSteps.getFieldError().should('contain.text', 'Must be at least 2 symbols long');
102
- // When I delete the invalid text
103
- UserAndAccessSteps.addTextToCustomRoleField('{backspace}');
104
- // Then the error should not be visible
105
- UserAndAccessSteps.getFieldError().should('not.be.visible');
106
- });
259
+ beforeEach(() => {
260
+ cy.viewport(1280, 1000);
261
+ RepositoriesStubs.spyGetRepositories();
262
+ repositoryId1 = 'user-access-repo1-' + Date.now();
263
+ repositoryId2 = 'user-access-repo2-' + Date.now();
264
+ repositoryId3 = 'user-access-repo3-' + Date.now();
265
+ cy.createRepository({id: repositoryId1});
266
+ cy.createRepository({id: repositoryId2});
267
+ cy.createRepository({id: repositoryId3});
268
+ cy.presetRepository(repositoryId1);
269
+ UserAndAccessSteps.visit();
270
+ // Users table should be visible
271
+ UserAndAccessSteps.getUsersTable().should('be.visible');
272
+ });
107
273
 
108
- it('Adding a role with a CUSTOM_ prefix shows a warning message', () => {
109
- // When I create a user
110
- UserAndAccessSteps.clickCreateNewUserButton();
111
- // And I add a custom role tag with prefix CUSTOM_
112
- UserAndAccessSteps.addTextToCustomRoleField('CUSTOM_USER{Enter}');
113
- // There should be a warning text
114
- UserAndAccessSteps.getPrefixWarning(0).should('contain', 'Custom roles should be entered without the "CUSTOM_" prefix in Workbench');
115
- });
274
+ afterEach(() => {
275
+ cy.loginAsAdmin().then(()=> {
276
+ cy.deleteRepository(repositoryId1, true);
277
+ cy.deleteRepository(repositoryId2, true);
278
+ cy.deleteRepository(repositoryId3, true);
279
+ cy.deleteUser(graphqlUser, true);
280
+ cy.switchOffFreeAccess(true);
281
+ cy.switchOffSecurity(true);
282
+ });
116
283
 
117
- it('Warn users when setting no password when creating new user admin', () => {
118
- UserAndAccessSteps.getUsersTable().should('be.visible');
119
- createUser("adminWithNoPassword", PASSWORD, ROLE_CUSTOM_ADMIN);
120
- UserAndAccessSteps.getUsersTable().should('be.visible');
121
- UserAndAccessSteps.getSplashLoader().should('not.be.visible');
122
- UserAndAccessSteps.deleteUser("adminWithNoPassword");
284
+ });
285
+
286
+ it('Can have Free Access and GraphQL working together', () => {
287
+ cy.wait('@getRepositories');
288
+ //enable security
289
+ UserAndAccessSteps.toggleSecurity();
290
+ //login with the admin
291
+ LoginSteps.loginWithUser("admin", DEFAULT_ADMIN_PASSWORD);
292
+ // The Free Access toggle should be OFF
293
+ UserAndAccessSteps.getFreeAccessSwitchInput().should('not.be.checked');
294
+ // When I toggle Free Access ON
295
+ UserAndAccessSteps.toggleFreeAccess();
296
+ // Then I set repo auths
297
+ UserAndAccessSteps.clickFreeReadAccessRepo(repositoryId1);
298
+ UserAndAccessSteps.clickFreeWriteAccessRepo(repositoryId2);
299
+ UserAndAccessSteps.clickFreeWriteAccessRepo(repositoryId3);
300
+ UserAndAccessSteps.clickFreeGraphqlAccessRepo(repositoryId3);
301
+ // Then I click OK in the modal
302
+ ModalDialogSteps.clickOKButton();
303
+ // Then the toggle button should be ON
304
+ UserAndAccessSteps.getFreeAccessSwitchInput().should('be.checked');
305
+ // And I should see a success message
306
+ ToasterSteps.verifySuccess('Free access has been enabled.');
307
+ UserAndAccessSteps.getUsersTable().should('be.visible');
308
+
309
+ // Then I logout
310
+ LoginSteps.logout();
311
+ HomeSteps.visit();
312
+ // I change the repository to this with GraphQL only rights
313
+ RepositorySelectorSteps.selectRepository(repositoryId3);
314
+ // Then I should have GraphQL only rights
315
+ FREE_ACCESS_MENU_ITEMS_WITHOUT_GRAPHQL.forEach(({path, expectedUrl, checks, expectedTitle}) => {
316
+ navigateMenuPath(path, expectedUrl, expectedTitle);
317
+ if (checks) {
318
+ runChecks(checks);
319
+ }
320
+ });
321
+ });
123
322
  });
124
323
 
125
- function createUser(username, password, role) {
324
+ function clickGraphqlAccessForRepo(repoName) {
325
+ if (repoName === '*') {
326
+ UserAndAccessSteps.clickGraphqlAccessAny();
327
+ } else {
328
+ UserAndAccessSteps.clickGraphqlAccessRepo(repoName);
329
+ }
330
+ }
331
+
332
+ function clickReadAccessForRepo(repoName) {
333
+ if (repoName === '*') {
334
+ UserAndAccessSteps.clickReadAccessAny();
335
+ } else {
336
+ UserAndAccessSteps.clickReadAccessRepo(repoName);
337
+ }
338
+ }
339
+
340
+ function clickWriteAccessForRepo(repoName) {
341
+ if (repoName === '*') {
342
+ UserAndAccessSteps.clickWriteAccessAny();
343
+ } else {
344
+ UserAndAccessSteps.clickWriteAccessRepo(repoName);
345
+ }
346
+ }
347
+
348
+ function createUser(username, password, role, opts = {}) {
126
349
  UserAndAccessSteps.clickCreateNewUserButton();
127
350
  UserAndAccessSteps.typeUsername(username);
128
351
  UserAndAccessSteps.typePassword(password);
129
352
  UserAndAccessSteps.typeConfirmPasswordField(password);
130
353
  UserAndAccessSteps.selectRoleRadioButton(role);
354
+ UserAndAccessSteps.getRoleRadioButton(role).should('be.checked');
355
+
131
356
  if (role === "#roleUser") {
132
- UserAndAccessSteps.getRepositoryRightsList().contains('Any data repository').nextUntil('.write').eq(1).within(() => {
133
- UserAndAccessSteps.clickWriteAccess();
134
- });
357
+ setRoles(opts);
135
358
  UserAndAccessSteps.confirmUserCreate();
136
- } else if (role === "#roleAdmin" && username === "adminWithNoPassword") {
359
+ } else if (role === ROLE_CUSTOM_ADMIN && opts.noPassword) {
137
360
  UserAndAccessSteps.getNoPasswordCheckbox().check()
138
361
  .then(() => {
139
362
  UserAndAccessSteps.getNoPasswordCheckbox()
@@ -152,11 +375,24 @@ describe('User and Access', () => {
152
375
  UserAndAccessSteps.getUsersTable().should('contain', username);
153
376
  }
154
377
 
378
+ function setRoles(opts = {}) {
379
+ const {read = false, readWrite = false, graphql = false, repoName = '*'} = opts;
380
+ if (read) {
381
+ clickReadAccessForRepo(repoName);
382
+ }
383
+ if (readWrite) {
384
+ clickWriteAccessForRepo(repoName);
385
+ }
386
+ if (graphql) {
387
+ clickGraphqlAccessForRepo(repoName);
388
+ }
389
+ }
390
+
155
391
  function testForUser(name, isAdmin) {
156
392
  //enable security
157
393
  UserAndAccessSteps.toggleSecurity();
158
394
  //login new user
159
- UserAndAccessSteps.loginWithUser(name, PASSWORD);
395
+ LoginSteps.loginWithUser(name, PASSWORD);
160
396
  //verify permissions
161
397
  UserAndAccessSteps.getUrl().should('include', '/users');
162
398
  if (isAdmin) {
@@ -165,16 +401,358 @@ describe('User and Access', () => {
165
401
  UserAndAccessSteps.getError().should('contain',
166
402
  'You have no permission to access this functionality with your current credentials.');
167
403
  }
168
- UserAndAccessSteps.logout();
169
- //login with the admin
170
- UserAndAccessSteps.loginWithUser("admin", DEFAULT_ADMIN_PASSWORD);
171
- UserAndAccessSteps.getSplashLoader().should('not.be.visible');
172
- UserAndAccessSteps.getUsersTable().should('be.visible');
173
- //delete new-user
174
- UserAndAccessSteps.deleteUser(name);
175
- //disable security
176
- UserAndAccessSteps.toggleSecurity();//.click({force: true});
177
- UserAndAccessSteps.getSecuritySwitchLabel().should('be.visible').and('contain', 'Security is OFF');
178
- UserAndAccessSteps.getUsersTable().should('be.visible');
179
404
  }
405
+
406
+ function assertUserAuths(username, {repo, read = false, write = false, graphql = false} = {}) {
407
+ UserAndAccessSteps.findUserRowAlias(username, 'userRow');
408
+
409
+ if(!read && !write) {
410
+ return UserAndAccessSteps.getRepoLine('@userRow', repo).should('not.exist');
411
+ }
412
+
413
+ UserAndAccessSteps.findRepoLineAlias('@userRow', repo, 'repoLine');
414
+
415
+ if (read) {
416
+ UserAndAccessSteps.findReadIconAlias('@repoLine').should('be.visible');
417
+ } else {
418
+ UserAndAccessSteps.findReadIconAlias('@repoLine').should('not.exist');
419
+
420
+ }
421
+
422
+ if (write) {
423
+ UserAndAccessSteps.findWriteIconAlias('@repoLine').should('be.visible');
424
+ } else {
425
+ UserAndAccessSteps.findWriteIconAlias('@repoLine').should('not.exist');
426
+ }
427
+
428
+ if (graphql) {
429
+ UserAndAccessSteps.findGraphqlIconAlias('@repoLine').should('exist');
430
+ } else {
431
+ UserAndAccessSteps.findGraphqlIconAlias('@repoLine').should('not.exist');
432
+ }
433
+ }
434
+
435
+ function editUserAuths({repo, read = false, write = false, graphql = false} = {}) {
436
+ if (read === true) {
437
+ UserAndAccessSteps.toggleReadAccessForRepo(repo);
438
+ }
439
+
440
+ if (write === true) {
441
+ UserAndAccessSteps.toggleWriteAccessForRepo(repo);
442
+ }
443
+
444
+ if (graphql === true) {
445
+ UserAndAccessSteps.toggleGraphqlAccessForRepo(repo);
446
+ }
447
+ }
448
+
449
+ function navigateMenuPath(pathArray, expectedUrl, expectedTitle) {
450
+ pathArray.forEach((label, index) => {
451
+ if (index === 0) {
452
+ UserAndAccessSteps.clickMenuItem(label);
453
+ } else {
454
+ UserAndAccessSteps.clickSubmenuItem(label);
455
+ const title = expectedTitle ? expectedTitle : label;
456
+ cy.get('h1').should('contain', title);
457
+ }
458
+ });
459
+
460
+ if (expectedUrl) {
461
+ cy.url().should('include', expectedUrl);
462
+ }
463
+ }
464
+
465
+ function runChecks(checks = {}) {
466
+ Object.entries(checks).forEach(([selector, assertions]) => {
467
+ let chain = cy.get(selector);
468
+
469
+ // assertions is an array, e.g. ["exist", ["contain.text", "Hello"], "be.visible"]
470
+ assertions.forEach((assertion, index) => {
471
+ if (index === 0) {
472
+ // First assertion = .should(...)
473
+ if (Array.isArray(assertion)) {
474
+ // e.g. ["contain.text", "Hello"]
475
+ chain = chain.should(...assertion);
476
+ } else {
477
+ // e.g. "exist"
478
+ chain = chain.should(assertion);
479
+ }
480
+ } else {
481
+ // Subsequent assertions = .and(...)
482
+ if (Array.isArray(assertion)) {
483
+ chain = chain.and(...assertion);
484
+ } else {
485
+ chain = chain.and(assertion);
486
+ }
487
+ }
488
+ });
489
+ });
490
+ }
491
+
492
+ const noAuthChecks = {
493
+ 'div[role="main]': [
494
+ 'not.exist'
495
+ ],
496
+ '.no-authority-panel .alert-warning': [
497
+ 'be.visible',
498
+ ['contains.text', 'Some functionalities are not available because'],
499
+ ['contains.text', 'you do not have the required repository permissions.']
500
+ ]
501
+ }
502
+
503
+ const hasAuthChecks = {
504
+ 'div[role="main"]': [
505
+ 'exist',
506
+ 'be.visible'
507
+ ],
508
+ '.no-authority-panel .alert-warning': [
509
+ 'not.exist'
510
+ ]
511
+ }
512
+
513
+ const MENU_ITEMS_WITHOUT_GRAPHQL = [
514
+ // 1) Import
515
+ {
516
+ path: ['Import'],
517
+ expectedUrl: '/import',
518
+ checks: noAuthChecks
519
+ },
520
+
521
+ // 2) Explore
522
+ {
523
+ path: ['Explore', 'Graphs overview'],
524
+ expectedUrl: '/graphs',
525
+ checks: noAuthChecks
526
+ },
527
+ {
528
+ path: ['Explore', 'Class hierarchy'],
529
+ expectedUrl: '/hierarchy',
530
+ checks: noAuthChecks
531
+ },
532
+ {
533
+ path: ['Explore', 'Class relationships'],
534
+ expectedUrl: '/relationships',
535
+ checks: noAuthChecks
536
+ },
537
+ {
538
+ path: ['Explore', 'Visual graph'],
539
+ expectedUrl: '/graphs-visualizations',
540
+ checks: noAuthChecks
541
+ },
542
+ {
543
+ path: ['Explore', 'Similarity'],
544
+ expectedTitle: 'Similarity indexes',
545
+ expectedUrl: '/similarity',
546
+ checks: noAuthChecks
547
+ },
548
+
549
+ // 3) SPARQL
550
+ {
551
+ path: ['SPARQL'],
552
+ expectedTitle: 'SPARQL Query & Update',
553
+ expectedUrl: '/sparql',
554
+ checks: noAuthChecks
555
+ },
556
+
557
+ // 4) GraphQL
558
+
559
+ // 5) Monitor
560
+ {
561
+ path: ['Monitor', 'Queries and Updates'],
562
+ expectedUrl: '/monitor/queries',
563
+ expectedTitle: 'Query and Update monitoring',
564
+ checks: noAuthChecks
565
+ },
566
+
567
+ // 6) Setup
568
+ {
569
+ path: ['Setup', 'My Settings'],
570
+ expectedUrl: '/settings',
571
+ expectedTitle: 'Settings',
572
+ checks: hasAuthChecks
573
+ },
574
+ {
575
+ path: ['Setup', 'Connectors'],
576
+ expectedUrl: '/connectors',
577
+ expectedTitle: 'Connector management',
578
+ checks: noAuthChecks
579
+ },
580
+ {
581
+ path: ['Setup', 'Cluster'],
582
+ expectedUrl: '/cluster',
583
+ expectedTitle: 'Cluster management',
584
+ checks: hasAuthChecks
585
+ },
586
+ {
587
+ path: ['Setup', 'Plugins'],
588
+ expectedUrl: '/plugins',
589
+ checks: noAuthChecks
590
+ },
591
+ {
592
+ path: ['Setup', 'Namespaces'],
593
+ expectedUrl: '/namespaces',
594
+ checks: noAuthChecks
595
+ },
596
+ {
597
+ path: ['Setup', 'Autocomplete'],
598
+ expectedUrl: '/autocomplete',
599
+ expectedTitle: 'Autocomplete index',
600
+ checks: noAuthChecks
601
+ },
602
+ {
603
+ path: ['Setup', 'RDF Rank'],
604
+ expectedUrl: '/rdfrank',
605
+ checks: noAuthChecks
606
+ },
607
+ {
608
+ path: ['Setup', 'JDBC'],
609
+ expectedUrl: '/jdbc',
610
+ expectedTitle: 'JDBC configuration',
611
+ checks: noAuthChecks
612
+ },
613
+ {
614
+ path: ['Setup', 'SPARQL Templates'],
615
+ expectedUrl: '/sparql-templates',
616
+ checks: noAuthChecks
617
+ },
618
+
619
+ // 7) Lab
620
+ {
621
+ path: ['Lab', 'Talk to Your Graph'],
622
+ expectedUrl: '/ttyg',
623
+ checks: noAuthChecks
624
+ },
625
+
626
+ // 8) Help
627
+ {
628
+ path: ['Help', 'REST API'],
629
+ expectedUrl: '/webapi',
630
+ expectedTitle: 'REST API documentation',
631
+ checks: hasAuthChecks
632
+ }
633
+ ];
634
+
635
+ const GRAPHQL_READ_MENU_ITEMS = [
636
+ {
637
+ path: ['GraphQL', 'GraphQL Playground'],
638
+ expectedUrl: '/graphql/playground',
639
+ checks: hasAuthChecks
640
+ }
641
+ ];
642
+ const GRAPHQL_REPO_MANAGER_MENU_ITEMS = [
643
+ {
644
+ path: ['GraphQL', 'Endpoint Management'],
645
+ expectedUrl: '/graphql/endpoints',
646
+ checks: hasAuthChecks
647
+ },
648
+ {
649
+ path: ['GraphQL', 'GraphQL Playground'],
650
+ expectedUrl: '/graphql/playground',
651
+ checks: hasAuthChecks
652
+ },
653
+ {
654
+ path: ['Monitor', 'Backup and Restore'],
655
+ expectedUrl: '/monitor/backup-and-restore',
656
+ checks: hasAuthChecks
657
+ },
658
+ {
659
+ path: ['Help', 'Interactive guides'],
660
+ expectedUrl: '/guides',
661
+ checks: hasAuthChecks
662
+ }
663
+ ];
664
+
665
+ const FREE_ACCESS_MENU_ITEMS_WITHOUT_GRAPHQL = [
666
+ // 1) Import
667
+ {
668
+ path: ['Import'],
669
+ expectedUrl: '/import',
670
+ checks: noAuthChecks
671
+ },
672
+
673
+ // 2) Explore
674
+ {
675
+ path: ['Explore', 'Graphs overview'],
676
+ expectedUrl: '/graphs',
677
+ checks: noAuthChecks
678
+ },
679
+ {
680
+ path: ['Explore', 'Class hierarchy'],
681
+ expectedUrl: '/hierarchy',
682
+ checks: noAuthChecks
683
+ },
684
+ {
685
+ path: ['Explore', 'Class relationships'],
686
+ expectedUrl: '/relationships',
687
+ checks: noAuthChecks
688
+ },
689
+ {
690
+ path: ['Explore', 'Visual graph'],
691
+ expectedUrl: '/graphs-visualizations',
692
+ checks: noAuthChecks
693
+ },
694
+ {
695
+ path: ['Explore', 'Similarity'],
696
+ expectedTitle: 'Similarity indexes',
697
+ expectedUrl: '/similarity',
698
+ checks: noAuthChecks
699
+ },
700
+
701
+ // 3) SPARQL
702
+ {
703
+ path: ['SPARQL'],
704
+ expectedTitle: 'SPARQL Query & Update',
705
+ expectedUrl: '/sparql',
706
+ checks: noAuthChecks
707
+ },
708
+
709
+
710
+ // 6) Setup
711
+ {
712
+ path: ['Setup', 'Connectors'],
713
+ expectedUrl: '/connectors',
714
+ expectedTitle: 'Connector management',
715
+ checks: noAuthChecks
716
+ },
717
+ {
718
+ path: ['Setup', 'Plugins'],
719
+ expectedUrl: '/plugins',
720
+ checks: noAuthChecks
721
+ },
722
+ {
723
+ path: ['Setup', 'Namespaces'],
724
+ expectedUrl: '/namespaces',
725
+ checks: noAuthChecks
726
+ },
727
+ {
728
+ path: ['Setup', 'Autocomplete'],
729
+ expectedUrl: '/autocomplete',
730
+ expectedTitle: 'Autocomplete index',
731
+ checks: noAuthChecks
732
+ },
733
+ {
734
+ path: ['Setup', 'RDF Rank'],
735
+ expectedUrl: '/rdfrank',
736
+ checks: noAuthChecks
737
+ },
738
+ {
739
+ path: ['Setup', 'JDBC'],
740
+ expectedUrl: '/jdbc',
741
+ expectedTitle: 'JDBC configuration',
742
+ checks: noAuthChecks
743
+ },
744
+ {
745
+ path: ['Setup', 'SPARQL Templates'],
746
+ expectedUrl: '/sparql-templates',
747
+ checks: noAuthChecks
748
+ },
749
+
750
+ // 7) Help
751
+ {
752
+ path: ['Help', 'REST API'],
753
+ expectedUrl: '/webapi',
754
+ expectedTitle: 'REST API documentation',
755
+ checks: hasAuthChecks
756
+ }
757
+ ];
180
758
  });