From eaef007982fd1494f3246f884ae264fb0424563a Mon Sep 17 00:00:00 2001 From: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Date: Thu, 17 Jun 2021 10:09:12 -0400 Subject: [PATCH] E2e test: addDockerHost to a specific team (#1116) * Add optional argument to addDockerHost for teams --- cypress/integration/basic/admin.spec.ts | 2 +- cypress/support/commands.ts | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cypress/integration/basic/admin.spec.ts b/cypress/integration/basic/admin.spec.ts index 7394684227..f68ff29817 100644 --- a/cypress/integration/basic/admin.spec.ts +++ b/cypress/integration/basic/admin.spec.ts @@ -6,7 +6,7 @@ if (Cypress.env("FLEET_TIER") === "basic") { cy.seedBasic(); cy.setupSMTP(); cy.seedQueries(); - cy.addDockerHost(); + cy.addDockerHost("oranges"); cy.logout(); }); afterEach(() => { diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 42636ff3f9..2e977bc6df 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -234,16 +234,25 @@ Cypress.Commands.add("addUser", (username, options = {}) => { ); }); -Cypress.Commands.add("addDockerHost", () => { +// Ability to add a docker host to a team using args if ran after seedBasic() +Cypress.Commands.add("addDockerHost", (team = "") => { const serverPort = new URL(Cypress.config().baseUrl).port; // Get enroll secret + let enrollSecretURL = "/api/v1/fleet/spec/enroll_secret"; + if (team === "apples") { + enrollSecretURL = "/api/v1/fleet/teams/1/secrets"; + } else if (team === "oranges") { + enrollSecretURL = "/api/v1/fleet/teams/2/secrets"; + } + cy.request({ - url: "/api/v1/fleet/spec/enroll_secret", + url: enrollSecretURL, auth: { bearer: window.localStorage.getItem("FLEET::auth_token"), }, }).then(({ body }) => { - const enrollSecret = body.specs.secrets[0].secret; + const enrollSecret = + team === "" ? body.specs.secrets[0].secret : body.secrets[0].secret; // Start up docker-compose with enroll secret cy.exec(