From a51d9df296fa297f2b21201d497ed48b4639c8e9 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 16 May 2022 15:21:56 -0300 Subject: [PATCH] 16115: Sets api_client as trusted in order to handle tokens. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- cypress/support/commands.js | 54 ++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index c2d78b54..74f44f7a 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -73,30 +73,48 @@ Cypress.Commands.add( }), return_to: ',https://example.local' }, null, systemToken, true, false) // Don't follow redirects so we can catch the token - .its('headers.location').as('location') - // Get its token and set the account up as admin and/or active + .its('headers.location').as('location') + // Get its token and set the account up as admin and/or active + .then(function () { + this.userToken = this.location.split("=")[1] + assert.isString(this.userToken) + return cy.doRequest('GET', '/arvados/v1/users', null, { + filters: `[["username", "=", "${username}"]]` + }) + .its('body.items.0').as('aUser') .then(function () { - this.userToken = this.location.split("=")[1] - assert.isString(this.userToken) - return cy.doRequest('GET', '/arvados/v1/users', null, { - filters: `[["username", "=", "${username}"]]` + cy.doRequest('PUT', `/arvados/v1/users/${this.aUser.uuid}`, { + user: { + is_admin: is_admin, + is_active: is_active + } }) - .its('body.items.0') - .as('aUser') + .its('body').as('theUser') + .then(function () { + cy.doRequest('GET', '/arvados/v1/api_clients', null, { + filters: `[["is_trusted", "=", false]]`, + order: `["created_at desc"]` + }) + .its('body.items').as('apiClients') .then(function () { - cy.doRequest('PUT', `/arvados/v1/users/${this.aUser.uuid}`, { - user: { - is_admin: is_admin, - is_active: is_active - } - }) - .its('body') - .as('theUser') - .then(function () { - return { user: this.theUser, token: this.userToken }; + if (this.apiClients.length > 0) { + cy.doRequest('PUT', `/arvados/v1/api_clients/${this.apiClients[0].uuid}`, { + api_client: { + is_trusted: true + } }) + .its('body').as('updatedApiClient') + .then(function() { + assert(this.updatedApiClient.is_trusted); + }) + } }) + .then(function () { + return { user: this.theUser, token: this.userToken }; + }) + }) }) + }) } ) -- 2.30.2