Skip to content

Commit e5d80e2

Browse files
committed
chore: acl tests
1 parent 9d2280e commit e5d80e2

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

tests/suites/tenant/summary/ObjectSummary.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export class ObjectSummary {
1818
private treeRows: Locator;
1919
private primaryKeys: Locator;
2020
private actionsMenu: ActionsMenu;
21+
private aclWrapper: Locator;
22+
private aclList: Locator;
23+
private effectiveAclList: Locator;
2124

2225
constructor(page: Page) {
2326
this.tree = page.locator('.ydb-object-summary__tree');
@@ -26,6 +29,49 @@ export class ObjectSummary {
2629
this.schemaViewer = page.locator('.schema-viewer');
2730
this.primaryKeys = page.locator('.schema-viewer__keys_type_primary');
2831
this.actionsMenu = new ActionsMenu(page.locator('.g-popup.g-popup_open'));
32+
this.aclWrapper = page.locator('.ydb-acl');
33+
this.aclList = this.aclWrapper.locator('dl.gc-definition-list').first();
34+
this.effectiveAclList = this.aclWrapper.locator('dl.gc-definition-list').last();
35+
}
36+
37+
async waitForAclVisible() {
38+
await this.aclWrapper.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
39+
return true;
40+
}
41+
42+
async getAccessRights(): Promise<{user: string; rights: string}[]> {
43+
await this.waitForAclVisible();
44+
const items = await this.aclList.locator('.gc-definition-list__item').all();
45+
const result = [];
46+
47+
for (const item of items) {
48+
const user =
49+
(await item.locator('.gc-definition-list__term-wrapper span').textContent()) || '';
50+
const definitionContent = await item.locator('.gc-definition-list__definition').first();
51+
const rights = (await definitionContent.textContent()) || '';
52+
result.push({user: user.trim(), rights: rights.trim()});
53+
}
54+
55+
return result;
56+
}
57+
58+
async getEffectiveAccessRights(): Promise<{group: string; permissions: string[]}[]> {
59+
await this.waitForAclVisible();
60+
const items = await this.effectiveAclList.locator('.gc-definition-list__item').all();
61+
const result = [];
62+
63+
for (const item of items) {
64+
const group =
65+
(await item.locator('.gc-definition-list__term-wrapper span').textContent()) || '';
66+
const definitionContent = await item.locator('.gc-definition-list__definition').first();
67+
const permissionElements = await definitionContent.locator('span').all();
68+
const permissions = await Promise.all(
69+
permissionElements.map(async (el) => ((await el.textContent()) || '').trim()),
70+
);
71+
result.push({group: group.trim(), permissions});
72+
}
73+
74+
return result;
2975
}
3076

3177
async isTreeVisible() {

tests/suites/tenant/summary/objectSummary.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,43 @@ test.describe('Object Summary', async () => {
160160
// Verify the column lists are different
161161
expect(vslotsColumns).not.toEqual(storagePoolsColumns);
162162
});
163+
164+
test.only('ACL tab shows correct access rights', async ({page}) => {
165+
const pageQueryParams = {
166+
schema: '/local/.sys_health',
167+
database: '/local',
168+
summaryTab: 'acl',
169+
tenantPage: 'query',
170+
};
171+
const tenantPage = new TenantPage(page);
172+
await tenantPage.goto(pageQueryParams);
173+
174+
const objectSummary = new ObjectSummary(page);
175+
await objectSummary.waitForAclVisible();
176+
177+
// Check Access Rights
178+
const accessRights = await objectSummary.getAccessRights();
179+
expect(accessRights).toEqual([{user: 'root@builtin', rights: 'Owner'}]);
180+
181+
// Check Effective Access Rights
182+
const effectiveRights = await objectSummary.getEffectiveAccessRights();
183+
expect(effectiveRights).toEqual([
184+
{group: 'USERS', permissions: ['ConnectDatabase']},
185+
{group: 'METADATA-READERS', permissions: ['List']},
186+
{group: 'DATA-READERS', permissions: ['SelectRow']},
187+
{group: 'DATA-WRITERS', permissions: ['UpdateRow', 'EraseRow']},
188+
{
189+
group: 'DDL-ADMINS',
190+
permissions: [
191+
'WriteAttributes',
192+
'CreateDirectory',
193+
'CreateTable',
194+
'RemoveSchema',
195+
'AlterSchema',
196+
],
197+
},
198+
{group: 'ACCESS-ADMINS', permissions: ['GrantAccessRights']},
199+
{group: 'DATABASE-ADMINS', permissions: ['Manage']},
200+
]);
201+
});
163202
});

0 commit comments

Comments
 (0)