diff --git a/cmd/e2e-setup/execute.go b/cmd/e2e-setup/execute.go index 8063d5d1f9..ef181725c9 100644 --- a/cmd/e2e-setup/execute.go +++ b/cmd/e2e-setup/execute.go @@ -17,6 +17,7 @@ import ( func execute(ctx context.Context, cmd *command.Commands, cfg E2EConfig, users []userData) error { ctx = authz.WithInstanceID(ctx, cfg.InstanceID) + ctx = authz.WithRequestedDomain(ctx, "localhost") orgOwner := newHuman(users[0]) @@ -92,6 +93,10 @@ func execute(ctx context.Context, cmd *command.Commands, cfg E2EConfig, users [] } if user.role != "" { + if _, err = cmd.AddInstanceMember(ctx, createdHuman.ID, domain.RoleIAMOwner); err != nil { + return err + } + if _, err = cmd.AddOrgMember(ctx, org.ResourceOwner, createdHuman.ID, user.role); err != nil { return err } diff --git a/console/cypress.config.ts b/console/cypress.config.ts index 34d6c5b382..087d1bc653 100644 --- a/console/cypress.config.ts +++ b/console/cypress.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'cypress'; +import { readFileSync } from 'fs'; export default defineConfig({ reporter: 'mochawesome', @@ -11,13 +12,21 @@ export default defineConfig({ }, chromeWebSecurity: false, - // experimentalSessionSupport: true, trashAssetsBeforeRuns: false, defaultCommandTimeout: 10000, e2e: { + experimentalSessionAndOrigin: true, setupNodeEvents(on, config) { - // implement node event listeners here + + require('cypress-terminal-report/src/installLogsPrinter')(on); + + config.defaultCommandTimeout = 10_000 + config.env.parsedServiceAccountKey = config.env.serviceAccountKey + if (config.env.serviceAccountKeyPath) { + config.env.parsedServiceAccountKey = JSON.parse(readFileSync(config.env.serviceAccountKeyPath, 'utf-8')) + } + return config }, }, }); diff --git a/console/cypress.sh b/console/cypress.sh index c7ae0f0a65..c96a7ee36b 100755 --- a/console/cypress.sh +++ b/console/cypress.sh @@ -16,6 +16,6 @@ if ! command -v cypress &> /dev/null; then fi $NPX cypress $ACTION \ - --port ${E2E_CYPRESS_PORT} \ + --port "${E2E_CYPRESSPORT}" \ --env org="${ZITADEL_E2E_ORG}",org_owner_password="${ZITADEL_E2E_ORGOWNERPW}",org_owner_viewer_password="${ZITADEL_E2E_ORGOWNERVIEWERPW}",org_project_creator_password="${ZITADEL_E2E_ORGPROJECTCREATORPW}",login_policy_user_password="${ZITADEL_E2E_LOGINPOLICYUSERPW}",password_complexity_user_password="${ZITADEL_E2E_PASSWORDCOMPLEXITYUSERPW}",consoleUrl="${ZITADEL_E2E_CONSOLEURL}",apiUrl="${ZITADEL_E2E_APIURL}",accountsUrl="${ZITADEL_E2E_ACCOUNTSURL}",issuerUrl="${ZITADEL_E2E_ISSUERURL}",serviceAccountKeyPath="${ZITADEL_E2E_MACHINEKEYPATH}",otherZitadelIdpInstance="${ZITADEL_E2E_OTHERZITADELIDPINSTANCE}",zitadelProjectResourceId="${ZITADEL_E2E_ZITADELPROJECTRESOURCEID}" \ "$@" diff --git a/console/cypress/plugins/index.ts b/console/cypress/plugins/index.ts deleted file mode 100644 index 7bca64c030..0000000000 --- a/console/cypress/plugins/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { readFileSync } from "fs"; - -module.exports = (on, config) => { - - require('cypress-terminal-report/src/installLogsPrinter')(on); - - config.defaultCommandTimeout = 10_000 - - config.env.parsedServiceAccountKey = config.env.serviceAccountKey - if (config.env.serviceAccountKeyPath) { - config.env.parsedServiceAccountKey = JSON.parse(readFileSync(config.env.serviceAccountKeyPath, 'utf-8')) - } - - return config -} diff --git a/e2e/local.env b/e2e/local.env index b5a841d4f1..ed7c44296f 100644 --- a/e2e/local.env +++ b/e2e/local.env @@ -11,5 +11,7 @@ ZITADEL_E2E_APIURL="http://localhost:8080" ZITADEL_E2E_ACCOUNTSURL="http://localhost:8080" ZITADEL_E2E_ISSUERURL="http://localhost:8080/oauth/v2" ZITADEL_E2E_OTHERZITADELIDPINSTANCE=false -ZITADEL_E2E_ZITADELPROJECTRESOURCEID="bignumber-$(echo -n $(./e2e/docker-compose.sh exec --no-TTY db cockroach sql --database zitadel --insecure --execute "select aggregate_id from eventstore.events where event_type = 'project.added' and event_data = '{\"name\": \"ZITADEL\"}';" --format tsv) | cut -d " " -f 2)" -ZITADEL_E2E_INSTANCEID="$(echo -n $(./e2e/docker-compose.sh exec --no-TTY db cockroach sql --database zitadel --insecure --execute "select aggregate_id from eventstore.events where event_type = 'instance.added' and event_data = '{\"name\": \"Localhost\"}';" --format tsv) | cut -d " " -f 2)" + +projectRoot=${projectRoot:-"."} +ZITADEL_E2E_ZITADELPROJECTRESOURCEID="bignumber-$(echo -n $(cd ${projectRoot}; ./e2e/docker-compose.sh exec --no-TTY db cockroach sql --database zitadel --insecure --execute "select aggregate_id from eventstore.events where event_type = 'project.added' and event_data = '{\"name\": \"ZITADEL\"}';" --format tsv) | cut -d " " -f 2)" +ZITADEL_E2E_INSTANCEID="$(echo -n $(cd ${projectRoot}; ./e2e/docker-compose.sh exec --no-TTY db cockroach sql --database zitadel --insecure --execute "select aggregate_id from eventstore.events where event_type = 'instance.added' and event_data = '{\"name\": \"Localhost\"}';" --format tsv) | cut -d " " -f 2)"