]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/cypress/integration/rgw/users.po.ts
buildsys: change download over to reef release
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / cypress / integration / rgw / users.po.ts
1 import { PageHelper } from '../page-helper.po';
2
3 const pages = {
4 index: { url: '#/rgw/user', id: 'cd-rgw-user-list' },
5 create: { url: '#/rgw/user/create', id: 'cd-rgw-user-form' }
6 };
7
8 export class UsersPageHelper extends PageHelper {
9 pages = pages;
10
11 @PageHelper.restrictTo(pages.create.url)
12 create(tenant: string, user_id: string, fullname: string, email: string, maxbuckets: string) {
13 // Enter in user_id
14 cy.get('#user_id').type(user_id);
15 // Show Tenanat
16 cy.get('#show_tenant').click({ force: true });
17 // Enter in tenant
18 cy.get('#tenant').type(tenant);
19 // Enter in full name
20 cy.get('#display_name').click().type(fullname);
21
22 // Enter in email
23 cy.get('#email').click().type(email);
24
25 // Enter max buckets
26 this.selectOption('max_buckets_mode', 'Custom');
27 cy.get('#max_buckets').should('exist').should('have.value', '1000');
28 cy.get('#max_buckets').click().clear().type(maxbuckets);
29
30 // Click the create button and wait for user to be made
31 cy.contains('button', 'Create User').click();
32 this.getFirstTableCell(tenant + '$' + user_id).should('exist');
33 }
34
35 @PageHelper.restrictTo(pages.index.url)
36 edit(name: string, new_fullname: string, new_email: string, new_maxbuckets: string) {
37 this.navigateEdit(name);
38
39 // Change the full name field
40 cy.get('#display_name').click().clear().type(new_fullname);
41
42 // Change the email field
43 cy.get('#email').click().clear().type(new_email);
44
45 // Change the max buckets field
46 this.selectOption('max_buckets_mode', 'Custom');
47 cy.get('#max_buckets').click().clear().type(new_maxbuckets);
48
49 cy.contains('button', 'Edit User').click();
50
51 // Click the user and check its details table for updated content
52 this.getExpandCollapseElement(name).click();
53 cy.get('.active.tab-pane')
54 .should('contain.text', new_fullname)
55 .and('contain.text', new_email)
56 .and('contain.text', new_maxbuckets);
57 }
58
59 invalidCreate() {
60 const tenant = '000invalid_tenant';
61 const uname = '000invalid_create_user';
62 // creating this user in order to check that you can't give two users the same name
63 this.navigateTo('create');
64 this.create(tenant, uname, 'xxx', 'xxx@xxx', '1');
65
66 this.navigateTo('create');
67
68 // Username
69 cy.get('#user_id')
70 // No username had been entered. Field should be invalid
71 .should('have.class', 'ng-invalid')
72 // Try to give user already taken name. Should make field invalid.
73 .type(uname);
74 cy.get('#show_tenant').click({ force: true });
75 cy.get('#tenant').type(tenant).should('have.class', 'ng-invalid');
76 cy.contains('#tenant + .invalid-feedback', 'The chosen user ID exists in this tenant.');
77
78 // check that username field is marked invalid if username has been cleared off
79 cy.get('#user_id').clear().blur().should('have.class', 'ng-invalid');
80 cy.contains('#user_id + .invalid-feedback', 'This field is required.');
81
82 // Full name
83 cy.get('#display_name')
84 // No display name has been given so field should be invalid
85 .should('have.class', 'ng-invalid')
86 // display name field should also be marked invalid if given input then emptied
87 .type('a')
88 .clear()
89 .blur()
90 .should('have.class', 'ng-invalid');
91 cy.contains('#display_name + .invalid-feedback', 'This field is required.');
92
93 // put invalid email to make field invalid
94 cy.get('#email').type('a').blur().should('have.class', 'ng-invalid');
95 cy.contains('#email + .invalid-feedback', 'This is not a valid email address.');
96
97 // put negative max buckets to make field invalid
98 this.expectSelectOption('max_buckets_mode', 'Custom');
99 cy.get('#max_buckets').clear().type('-5').blur().should('have.class', 'ng-invalid');
100 cy.contains('#max_buckets + .invalid-feedback', 'The entered value must be >= 1.');
101
102 this.navigateTo();
103 this.delete(tenant + '$' + uname);
104 }
105
106 invalidEdit() {
107 const tenant = '000invalid_tenant';
108 const uname = '000invalid_edit_user';
109 // creating this user to edit for the test
110 this.navigateTo('create');
111 this.create(tenant, uname, 'xxx', 'xxx@xxx', '50');
112 const name = tenant + '$' + uname;
113 this.navigateEdit(name);
114
115 // put invalid email to make field invalid
116 cy.get('#email')
117 .clear()
118 .type('a')
119 .blur()
120 .should('not.have.class', 'ng-pending')
121 .should('have.class', 'ng-invalid');
122 cy.contains('#email + .invalid-feedback', 'This is not a valid email address.');
123
124 // empty the display name field making it invalid
125 cy.get('#display_name').clear().blur().should('have.class', 'ng-invalid');
126 cy.contains('#display_name + .invalid-feedback', 'This field is required.');
127
128 // put negative max buckets to make field invalid
129 this.selectOption('max_buckets_mode', 'Disabled');
130 cy.get('#max_buckets').should('not.exist');
131 this.selectOption('max_buckets_mode', 'Custom');
132 cy.get('#max_buckets').should('exist').should('have.value', '50');
133 cy.get('#max_buckets').clear().type('-5').blur().should('have.class', 'ng-invalid');
134 cy.contains('#max_buckets + .invalid-feedback', 'The entered value must be >= 1.');
135
136 this.navigateTo();
137 this.delete(tenant + '$' + uname);
138 }
139 }