Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional Tests : functional/BO/14*/12*/03* : Changes for Token Lifetime #34459

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('BO - Advanced Parameter - Authorization Server : Edit API Access', asy
clientName: 'API Access UVW',
clientId: 'api-access-uvw',
description: 'Description DEF',
tokenLifetime: 5,
});

// Pre-condition: Enable experimental feature : Authorization server
Expand Down Expand Up @@ -86,6 +87,13 @@ describe('BO - Advanced Parameter - Authorization Server : Edit API Access', asy
expect(textResult).to.equal(addNewApiAccessPage.successfulUpdateMessage);
});

it('should check information', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkInformations', baseContext);

const tokenLifetime = await addNewApiAccessPage.getValue(page, 'tokenLifetime');
expect(tokenLifetime).to.be.equal(editAPIAccess.tokenLifetime.toString());
});

it('should regenerate the client secret', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'regenerateClientSecret', baseContext);

Expand Down
7 changes: 6 additions & 1 deletion tests/UI/data/faker/APIAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export default class APIAccessData {

public readonly description: string;

public readonly tokenLifetime: number;

/**
* Constructor for class APIAccessData
* @param apiAccessToCreate {APIAccessCreator} Could be used to force the value of some members
Expand All @@ -29,7 +31,10 @@ export default class APIAccessData {
/** @type {string} API Access ID */
this.clientId = apiAccessToCreate.clientId || faker.string.uuid();

/** @type {string} Customer firstname */
/** @type {string} Description */
this.description = apiAccessToCreate.description || faker.lorem.sentence();

/** @type {string} Token Lifetime */
this.tokenLifetime = apiAccessToCreate.tokenLifetime || 3600;
}
}
1 change: 1 addition & 0 deletions tests/UI/data/types/APIAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ type APIAccessCreator = {
clientName?: string
clientId?: string
description?: string
tokenLifetime?: number
};

export default APIAccessCreator;
18 changes: 18 additions & 0 deletions tests/UI/pages/BO/advancedParameters/APIAccess/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class AddNewAPIAccess extends BOBasePage {

private readonly descriptionInput: string;

private readonly tokenLifetimeInput: string;

private readonly saveButton: string;

private readonly generateClientSecret: string;
Expand Down Expand Up @@ -60,6 +62,7 @@ class AddNewAPIAccess extends BOBasePage {
this.clientNameInput = `${this.formAPIAccess} #api_access_client_name`;
this.clientIdInput = `${this.formAPIAccess} #api_access_client_id`;
this.descriptionInput = `${this.formAPIAccess} #api_access_description`;
this.tokenLifetimeInput = `${this.formAPIAccess} #api_access_lifetime`;
this.saveButton = `${this.formAPIAccess} .card-footer button`;
this.generateClientSecret = `${this.formAPIAccess} .card-footer .generate-client-secret`;
this.modalDialogConfirmButton = '#generate-secret-modal .modal-footer .btn-confirm-submit';
Expand All @@ -79,12 +82,27 @@ class AddNewAPIAccess extends BOBasePage {
await this.setValue(page, this.clientNameInput, apiAccessData.clientName);
await this.setValue(page, this.clientIdInput, apiAccessData.clientId);
await this.setValue(page, this.descriptionInput, apiAccessData.description);
await this.setValue(page, this.tokenLifetimeInput, apiAccessData.tokenLifetime);
// Save
await this.clickAndWaitForURL(page, this.saveButton);

return this.getAlertSuccessBlockParagraphContent(page);
}

/**
* Return input value
* @param page {Page}
* @param inputName {string}
*/
async getValue(page: Page, inputName: string): Promise<string> {
switch (inputName) {
case 'tokenLifetime':
return this.getAttributeContent(page, this.tokenLifetimeInput, 'value');
default:
throw new Error(`Input ${inputName} was not found`);
}
}

/**
* Regenerate the client secret
* @param page {Page} Browser tab
Expand Down