Skip to content

Commit

Permalink
vai pagination tests - tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonas Berhe authored and Yonas Berhe committed Jun 22, 2024
1 parent bb4206f commit 14c8ae9
Show file tree
Hide file tree
Showing 6 changed files with 406 additions and 78 deletions.
167 changes: 167 additions & 0 deletions cypress/e2e/blueprints/account-and-apikeys/tokens-get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
// GET /v3/tokens - return empty tokens data
const tokensGetResponseEmptySet = {
type: 'collection',
links: { self: 'https://yonasb29.qa.rancher.space/v3/tokens' },
createTypes: { token: 'https://yonasb29.qa.rancher.space/v3/tokens' },
actions: {},
pagination: { limit: 1000 },
resourceType: 'token',
data: []
};

// GET /v3/tokens - small set of tokens data
const tokensGetResponseSmallSet = {
type: 'collection',
links: { self: 'https://yonasb29.qa.rancher.space/v3/tokens' },
createTypes: { token: 'https://yonasb29.qa.rancher.space/v3/tokens' },
actions: {},
pagination: { limit: 1000 },
sort: {
order: 'asc',
reverse: 'https://yonasb29.qa.rancher.space/v3/tokens?order=desc',
links: {
authProvider: 'https://yonasb29.qa.rancher.space/v3/tokens?sort=authProvider',
description: 'https://yonasb29.qa.rancher.space/v3/tokens?sort=description',
expiresAt: 'https://yonasb29.qa.rancher.space/v3/tokens?sort=expiresAt',
lastUpdateTime: 'https://yonasb29.qa.rancher.space/v3/tokens?sort=lastUpdateTime',
token: 'https://yonasb29.qa.rancher.space/v3/tokens?sort=token',
uuid: 'https://yonasb29.qa.rancher.space/v3/tokens?sort=uuid'
}
},
filters: {
authProvider: null,
clusterId: null,
created: null,
creatorId: null,
current: null,
description: null,
enabled: null,
expired: null,
expiresAt: null,
isDerived: null,
lastUpdateTime: null,
name: null,
removed: null,
token: null,
ttl: null,
userId: null,
userPrincipal: null,
uuid: null
},
resourceType: 'token',
data: [
{
authProvider: 'local',
baseType: 'token',
clusterId: null,
created: '2024-06-17T17:32:07Z',
createdTS: 1718645527000,
creatorId: null,
current: false,
description: 'Kubeconfig token',
enabled: true,
expired: false,
expiresAt: '2024-07-17T17:32:07Z',
id: 'aaa-e2e-vai-test-token-name',
isDerived: true,
labels: {
'authn.management.cattle.io/kind': 'kubeconfig',
'authn.management.cattle.io/token-userId': 'user-btq9q',
'cattle.io/creator': 'norman'
},
lastUpdateTime: '',
links: {
remove: 'https://yonasb29.qa.rancher.space/v3/tokens/kubeconfig-user-btq9q8dl9x',
self: 'https://yonasb29.qa.rancher.space/v3/tokens/kubeconfig-user-btq9q8dl9x',
update: 'https://yonasb29.qa.rancher.space/v3/tokens/kubeconfig-user-btq9q8dl9x'
},
name: 'kubeconfig-user-btq9q8dl9x',
ttl: 2592000000,
type: 'token',
userId: 'user-btq9q',
userPrincipal: 'map[displayName:Default Admin loginName:admin me:true metadata:map[creationTimestamp:<nil> name:local://user-btq9q] principalType:user provider:local]',
uuid: 'd801c997-fd36-4ed1-8835-7a741a302b26'
},
{
authProvider: 'local',
baseType: 'token',
clusterId: null,
created: '2024-06-17T17:29:05Z',
createdTS: 1718645345000,
creatorId: null,
current: false,
description: 'Kubeconfig token',
enabled: true,
expired: false,
expiresAt: '2024-07-17T17:29:05Z',
id: 'kubeconfig-user-btq9q98fn7',
isDerived: true,
labels: {
'authn.management.cattle.io/kind': 'kubeconfig',
'authn.management.cattle.io/token-userId': 'user-btq9q',
'cattle.io/creator': 'norman'
},
lastUpdateTime: '',
links: {
remove: 'https://yonasb29.qa.rancher.space/v3/tokens/kubeconfig-user-btq9q98fn7',
self: 'https://yonasb29.qa.rancher.space/v3/tokens/kubeconfig-user-btq9q98fn7',
update: 'https://yonasb29.qa.rancher.space/v3/tokens/kubeconfig-user-btq9q98fn7'
},
name: 'kubeconfig-user-btq9q98fn7',
ttl: 2592000000,
type: 'token',
userId: 'user-btq9q',
userPrincipal: 'map[displayName:Default Admin loginName:admin me:true metadata:map[creationTimestamp:<nil> name:local://user-btq9q] principalType:user provider:local]',
uuid: 'f1003a82-8923-4a8c-831a-94e72f9576ff'
},
{
authProvider: 'local',
baseType: 'token',
clusterId: null,
created: '2024-06-17T17:32:06Z',
createdTS: 1718645526000,
creatorId: null,
current: false,
description: 'Kubeconfig token',
enabled: true,
expired: false,
expiresAt: '2024-07-17T17:32:06Z',
id: 'kubeconfig-user-btq9q9p8lv',
isDerived: true,
labels: {
'authn.management.cattle.io/kind': 'kubeconfig',
'authn.management.cattle.io/token-userId': 'user-btq9q',
'cattle.io/creator': 'norman'
},
lastUpdateTime: '',
links: {
remove: 'https://yonasb29.qa.rancher.space/v3/tokens/kubeconfig-user-btq9q9p8lv',
self: 'https://yonasb29.qa.rancher.space/v3/tokens/kubeconfig-user-btq9q9p8lv',
update: 'https://yonasb29.qa.rancher.space/v3/tokens/kubeconfig-user-btq9q9p8lv'
},
name: 'kubeconfig-user-btq9q9p8lv',
ttl: 2592000000,
type: 'token',
userId: 'user-btq9q',
userPrincipal: 'map[displayName:Default Admin loginName:admin me:true metadata:map[creationTimestamp:<nil> name:local://user-btq9q] principalType:user provider:local]',
uuid: '82a1bc74-51a6-4230-aaa8-bb308712fcb8'
}
]
};

function reply(statusCode: number, body: any) {
return (req) => {
req.reply({
statusCode,
body
});
};
}

export function tokensNoData(): Cypress.Chainable<Response> {
return cy.intercept('GET', '/v3/tokens', reply(200, tokensGetResponseEmptySet)).as('tokensNoData');
}

export function generateTokensDataSmall(): Cypress.Chainable<Response> {
return cy.intercept('GET', '/v3/tokens', reply(200, tokensGetResponseSmallSet)).as('tokensDataSmall');
}
7 changes: 7 additions & 0 deletions cypress/e2e/po/pages/account-api-keys.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,11 @@ export default class AccountPagePo extends PagePo {
confirmPassword(): PasswordPo {
return new PasswordPo('[data-testid="account__confirm_password"]');
}

/**
* Convenience method
*/
sortableTable() {
return this.list().resourceTable().sortableTable();
}
}
22 changes: 0 additions & 22 deletions cypress/e2e/tests/pages/explorer/workloads/pods.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe('Pods', { testIsolation: 'off', tags: ['@explorer', '@adminUser'] }, ()
before('set up', () => {
cy.updateResourceListViewPref('local', 'none', '{\"local\":[]}');

<<<<<<< HEAD
// create ns
cy.createNamespace(nsName);

Expand All @@ -28,14 +27,6 @@ describe('Pods', { testIsolation: 'off', tags: ['@explorer', '@adminUser'] }, ()
while (i < 100) {
const podName = `e2e-${ Cypress._.uniqueId(Date.now().toString()) }`;

=======
// create pods
let i = 0;

while (i < 100) {
const podName = `e2e-${ Cypress._.uniqueId(Date.now().toString()) }`;

>>>>>>> 76f7b166a (vai pagination tests - pods)
cy.createPod(nsName, podName, 'nginx:latest', false).then(() => {
podNamesList.push(`pod-${ podName }`);
});
Expand Down Expand Up @@ -120,20 +111,11 @@ describe('Pods', { testIsolation: 'off', tags: ['@explorer', '@adminUser'] }, ()
// filter by name
workloadsPodPage.sortableTable().filter(podNamesList[0]);
workloadsPodPage.sortableTable().checkRowCount(false, 1);
<<<<<<< HEAD
workloadsPodPage.sortableTable().rowElementWithName(podNamesList[0]).should('be.visible');

// filter by namespace
workloadsPodPage.sortableTable().filter('cattle-system');
workloadsPodPage.sortableTable().rowElementWithName(`pod-${ singlePod }`).should('be.visible');
=======
workloadsPodPage.sortableTable().rowElementWithName(podNamesList[0]).scrollIntoView().should('be.visible');

// filter by namespace
workloadsPodPage.sortableTable().filter('cattle-system');
workloadsPodPage.sortableTable().checkRowCount(false, 1);
workloadsPodPage.sortableTable().rowElementWithName(`pod-${ singlePod }`).scrollIntoView().should('be.visible');
>>>>>>> 76f7b166a (vai pagination tests - pods)
});

it('sorting changes the order of paginated pods data', () => {
Expand Down Expand Up @@ -277,14 +259,10 @@ describe('Pods', { testIsolation: 'off', tags: ['@explorer', '@adminUser'] }, ()
});

after(() => {
<<<<<<< HEAD
// delete project and ns
cy.deleteRancherResource('v1', 'namespaces', nsName);

// delete single pod
=======
podNamesList.forEach((r) => cy.deleteRancherResource('v1', `pods/${ nsName }`, r, false));
>>>>>>> 76f7b166a (vai pagination tests - pods)
cy.deleteRancherResource('v1', 'pods/cattle-system', `pod-${ singlePod }`, false);
});
});
Loading

0 comments on commit 14c8ae9

Please sign in to comment.