mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 18:33:28 +00:00
feat: add quotas (#4779)
adds possibilities to cap authenticated requests and execution seconds of actions on a defined intervall
This commit is contained in:
@@ -1,22 +1,26 @@
|
||||
import { Apps, ensureProjectExists, ensureProjectResourceDoesntExist } from '../../support/api/projects';
|
||||
import { apiAuth } from '../../support/api/apiauth';
|
||||
import { Context } from 'support/commands';
|
||||
|
||||
const testProjectName = 'e2eprojectapplication';
|
||||
const testAppName = 'e2eappundertest';
|
||||
|
||||
describe('applications', () => {
|
||||
const testProjectName = 'e2eprojectapplication';
|
||||
const testAppName = 'e2eappundertest';
|
||||
|
||||
beforeEach(() => {
|
||||
apiAuth()
|
||||
.as('api')
|
||||
.then((api) => {
|
||||
ensureProjectExists(api, testProjectName).as('projectId');
|
||||
cy.context()
|
||||
.as('ctx')
|
||||
.then((ctx) => {
|
||||
ensureProjectExists(ctx.api, testProjectName).as('projectId');
|
||||
});
|
||||
});
|
||||
|
||||
describe('add app', function () {
|
||||
beforeEach(`ensure it doesn't exist already`, function () {
|
||||
ensureProjectResourceDoesntExist(this.api, this.projectId, Apps, testAppName);
|
||||
cy.visit(`/projects/${this.projectId}`);
|
||||
describe('add app', () => {
|
||||
beforeEach(`ensure it doesn't exist already`, () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
cy.get<string>('@projectId').then((projectId) => {
|
||||
ensureProjectResourceDoesntExist(ctx.api, projectId, Apps, testAppName);
|
||||
cy.visit(`/projects/${projectId}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('add app', () => {
|
||||
|
@@ -1,25 +1,28 @@
|
||||
import { apiAuth } from '../../support/api/apiauth';
|
||||
import { ensureHumanUserExists, ensureUserDoesntExist } from '../../support/api/users';
|
||||
import { loginname } from '../../support/login/users';
|
||||
import { ensureDomainPolicy } from '../../support/api/policies';
|
||||
import { Context } from 'support/commands';
|
||||
|
||||
describe('humans', () => {
|
||||
const humansPath = `/users?type=human`;
|
||||
|
||||
beforeEach(() => {
|
||||
cy.context().as('ctx');
|
||||
});
|
||||
|
||||
[
|
||||
{ mustBeDomain: false, addName: 'e2ehumanusernameaddGlobal', removeName: 'e2ehumanusernameremoveGlobal' },
|
||||
{ mustBeDomain: false, addName: 'e2ehumanusernameadd@test.com', removeName: 'e2ehumanusernameremove@test.com' },
|
||||
{ mustBeDomain: true, addName: 'e2ehumanusernameadd', removeName: 'e2ehumanusernameremove' },
|
||||
// TODO:Changing the policy return 409 User already exists (SQL-M0dsf)
|
||||
// { mustBeDomain: true, addName: 'e2ehumanusernameadd', removeName: 'e2ehumanusernameremove' },
|
||||
].forEach((user) => {
|
||||
beforeEach(() => {
|
||||
apiAuth().as('api');
|
||||
});
|
||||
|
||||
describe(`add "${user.addName}" with domain setting "${user.mustBeDomain}"`, () => {
|
||||
beforeEach(`ensure it doesn't exist already`, function () {
|
||||
ensureDomainPolicy(this.api, user.mustBeDomain, true, false);
|
||||
ensureUserDoesntExist(this.api, user.addName);
|
||||
cy.visit(humansPath);
|
||||
beforeEach(`ensure it doesn't exist already`, () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureUserDoesntExist(ctx.api, user.addName);
|
||||
ensureDomainPolicy(ctx.api, user.mustBeDomain, true, false);
|
||||
cy.visit(humansPath);
|
||||
});
|
||||
});
|
||||
|
||||
it('should add a user', () => {
|
||||
@@ -44,19 +47,17 @@ describe('humans', () => {
|
||||
});
|
||||
|
||||
describe(`remove "${user.removeName}" with domain setting "${user.mustBeDomain}"`, () => {
|
||||
beforeEach('ensure it exists', function () {
|
||||
ensureHumanUserExists(this.api, user.removeName);
|
||||
beforeEach('ensure it exists', () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureHumanUserExists(ctx.api, user.removeName);
|
||||
});
|
||||
cy.visit(humansPath);
|
||||
});
|
||||
|
||||
let loginName = user.removeName;
|
||||
if (user.mustBeDomain) {
|
||||
loginName = loginname(user.removeName, Cypress.env('ORGANIZATION'));
|
||||
}
|
||||
it('should delete a human user', () => {
|
||||
const rowSelector = `tr:contains(${user.removeName})`;
|
||||
cy.get(rowSelector).find('[data-e2e="enabled-delete-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(loginName);
|
||||
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(user.removeName);
|
||||
cy.get('[data-e2e="confirm-dialog-button"]').click();
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.shouldNotExist({
|
||||
|
23
e2e/cypress/e2e/i18n/api.cy.ts
Normal file
23
e2e/cypress/e2e/i18n/api.cy.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { getInstance } from 'support/api/instances';
|
||||
import { ensureQuotaIsRemoved, removeQuota, Unit } from 'support/api/quota';
|
||||
import { Context } from 'support/commands';
|
||||
|
||||
describe('api internationalization', () => {
|
||||
beforeEach(() => {
|
||||
cy.context()
|
||||
.as('ctx')
|
||||
.then((ctx) => {
|
||||
ensureQuotaIsRemoved(ctx, Unit.ExecutionSeconds);
|
||||
});
|
||||
});
|
||||
it('instance not found error should be translated', () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
removeQuota(ctx, Unit.ExecutionSeconds, false).then((res) => {
|
||||
expect(res.body.message).to.contain('Quota not found for this unit');
|
||||
});
|
||||
getInstance(ctx.system, "this ID clearly doesn't exist", false).then((res) => {
|
||||
expect(res.body.message).to.contain('Instance not found');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@@ -1,25 +1,28 @@
|
||||
import { apiAuth } from '../../support/api/apiauth';
|
||||
import { ensureMachineUserExists, ensureUserDoesntExist } from '../../support/api/users';
|
||||
import { loginname } from '../../support/login/users';
|
||||
import { ensureDomainPolicy } from '../../support/api/policies';
|
||||
import { Context } from 'support/commands';
|
||||
|
||||
describe('machines', () => {
|
||||
const machinesPath = `/users?type=machine`;
|
||||
|
||||
beforeEach(() => {
|
||||
apiAuth().as('api');
|
||||
cy.context().as('ctx');
|
||||
});
|
||||
|
||||
[
|
||||
{ mustBeDomain: false, addName: 'e2emachineusernameaddGlobal', removeName: 'e2emachineusernameremoveGlobal' },
|
||||
{ mustBeDomain: false, addName: 'e2emachineusernameadd@test.com', removeName: 'e2emachineusernameremove@test.com' },
|
||||
{ mustBeDomain: true, addName: 'e2emachineusernameadd', removeName: 'e2emachineusernameremove' },
|
||||
// TODO:Changing the policy return 409 User already exists (SQL-M0dsf)
|
||||
// { mustBeDomain: true, addName: 'e2emachineusernameadd', removeName: 'e2emachineusernameremove' },
|
||||
].forEach((machine) => {
|
||||
describe(`add "${machine.addName}" with domain setting "${machine.mustBeDomain}"`, () => {
|
||||
beforeEach(`ensure it doesn't exist already`, function () {
|
||||
ensureDomainPolicy(this.api, machine.mustBeDomain, false, false);
|
||||
ensureUserDoesntExist(this.api, machine.addName);
|
||||
cy.visit(machinesPath);
|
||||
beforeEach(`ensure it doesn't exist already`, () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureUserDoesntExist(ctx.api, machine.addName);
|
||||
ensureDomainPolicy(ctx.api, machine.mustBeDomain, false, false);
|
||||
cy.visit(machinesPath);
|
||||
});
|
||||
});
|
||||
|
||||
it('should add a machine', () => {
|
||||
@@ -41,9 +44,11 @@ describe('machines', () => {
|
||||
});
|
||||
|
||||
describe(`remove "${machine.removeName}" with domain setting "${machine.mustBeDomain}"`, () => {
|
||||
beforeEach('ensure it exists', function () {
|
||||
ensureMachineUserExists(this.api, machine.removeName);
|
||||
cy.visit(machinesPath);
|
||||
beforeEach('ensure it exists', () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureMachineUserExists(ctx.api, machine.removeName);
|
||||
cy.visit(machinesPath);
|
||||
});
|
||||
});
|
||||
|
||||
let loginName = machine.removeName;
|
||||
|
@@ -1,26 +1,25 @@
|
||||
import { ensureOrgExists, ensureOrgIsDefault, isDefaultOrg } from 'support/api/orgs';
|
||||
import { apiAuth } from '../../support/api/apiauth';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { Context } from 'support/commands';
|
||||
|
||||
const orgPath = `/org`;
|
||||
|
||||
const orgNameOnCreation = 'e2eorgrename';
|
||||
const testOrgNameChange = uuidv4();
|
||||
|
||||
beforeEach(() => {
|
||||
cy.context().as('ctx');
|
||||
});
|
||||
|
||||
describe('organizations', () => {
|
||||
describe('rename', () => {
|
||||
beforeEach(() => {
|
||||
apiAuth()
|
||||
.as('api')
|
||||
.then((api) => {
|
||||
ensureOrgExists(api, orgNameOnCreation)
|
||||
.as('newOrgId')
|
||||
.then((newOrgId) => {
|
||||
cy.visit(`${orgPath}?org=${newOrgId}`).as('orgsite');
|
||||
});
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureOrgExists(ctx, orgNameOnCreation).then((newOrgId) => {
|
||||
cy.visit(`${orgPath}?org=${newOrgId}`).as('orgsite');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should rename the organization', () => {
|
||||
cy.get('[data-e2e="actions"]').click();
|
||||
cy.get('[data-e2e="rename"]', { timeout: 1000 }).should('be.visible').click();
|
||||
@@ -31,24 +30,21 @@ describe('organizations', () => {
|
||||
cy.visit(orgPath);
|
||||
cy.get('[data-e2e="top-view-title"').should('contain', testOrgNameChange);
|
||||
});
|
||||
});
|
||||
|
||||
const orgOverviewPath = `/orgs`;
|
||||
const initialDefaultOrg = 'e2eorgolddefault';
|
||||
const orgNameForNewDefault = 'e2eorgnewdefault';
|
||||
const orgOverviewPath = `/orgs`;
|
||||
const initialDefaultOrg = 'e2eorgolddefault';
|
||||
const orgNameForNewDefault = 'e2eorgnewdefault';
|
||||
|
||||
describe('set default org', () => {
|
||||
beforeEach(() => {
|
||||
apiAuth()
|
||||
.as('api')
|
||||
.then((api) => {
|
||||
ensureOrgExists(api, orgNameForNewDefault)
|
||||
describe('set default org', () => {
|
||||
beforeEach(() => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureOrgExists(ctx, orgNameForNewDefault)
|
||||
.as('newDefaultOrgId')
|
||||
.then(() => {
|
||||
ensureOrgExists(api, initialDefaultOrg)
|
||||
ensureOrgExists(ctx, initialDefaultOrg)
|
||||
.as('defaultOrg')
|
||||
.then((id) => {
|
||||
ensureOrgIsDefault(api, id)
|
||||
ensureOrgIsDefault(ctx, id)
|
||||
.as('orgWasDefault')
|
||||
.then(() => {
|
||||
cy.visit(`${orgOverviewPath}`).as('orgsite');
|
||||
@@ -56,19 +52,24 @@ describe('organizations', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should rename the organization', () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
const rowSelector = `tr:contains(${orgNameForNewDefault})`;
|
||||
cy.get(rowSelector).find('[data-e2e="table-actions-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="set-default-button"]', { timeout: 1000 }).should('be.visible').click();
|
||||
cy.shouldConfirmSuccess();
|
||||
cy.get<string>('@newDefaultOrgId').then((newDefaultOrgId) => {
|
||||
isDefaultOrg(ctx, newDefaultOrgId);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should rename the organization', function () {
|
||||
const rowSelector = `tr:contains(${orgNameForNewDefault})`;
|
||||
cy.get(rowSelector).find('[data-e2e="table-actions-button"]').click({ force: true });
|
||||
cy.get('[data-e2e="set-default-button"]', { timeout: 1000 }).should('be.visible').click();
|
||||
cy.shouldConfirmSuccess();
|
||||
isDefaultOrg(this.api, this.newDefaultOrgId);
|
||||
it('should add an organization with the personal account as org owner');
|
||||
describe('changing the current organization', () => {
|
||||
it('should update displayed organization details');
|
||||
});
|
||||
});
|
||||
|
||||
it('should add an organization with the personal account as org owner');
|
||||
describe('changing the current organization', () => {
|
||||
it('should update displayed organization details');
|
||||
});
|
||||
});
|
||||
|
@@ -6,36 +6,46 @@ import {
|
||||
ensureHumanIsProjectMember,
|
||||
} from 'support/api/members';
|
||||
import { ensureOrgExists } from 'support/api/orgs';
|
||||
import { ensureDomainPolicy } from 'support/api/policies';
|
||||
import { ensureHumanUserExists, ensureUserDoesntExist } from 'support/api/users';
|
||||
import { loginname } from 'support/login/users';
|
||||
import { apiAuth } from '../../support/api/apiauth';
|
||||
import { Context } from 'support/commands';
|
||||
import { ensureProjectExists, ensureProjectResourceDoesntExist, Roles } from '../../support/api/projects';
|
||||
|
||||
describe('permissions', () => {
|
||||
beforeEach(() => {
|
||||
apiAuth().as('api');
|
||||
cy.context()
|
||||
.as('ctx')
|
||||
.then((ctx) => {
|
||||
ensureDomainPolicy(ctx.api, false, true, false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('management', () => {
|
||||
const testManagerLoginname = loginname('e2ehumanmanager', Cypress.env('ORGANIZATION'));
|
||||
const testManagerUsername = 'e2ehumanmanager';
|
||||
function testAuthorizations(
|
||||
roles: string[],
|
||||
beforeCreate: Mocha.HookFunction,
|
||||
beforeMutate: Mocha.HookFunction,
|
||||
navigate: Mocha.HookFunction,
|
||||
beforeCreate: (ctx: Context) => void,
|
||||
beforeMutate: (ctx: Context) => void,
|
||||
navigate: () => void,
|
||||
) {
|
||||
beforeEach(function () {
|
||||
ensureUserDoesntExist(this.api, testManagerLoginname);
|
||||
ensureHumanUserExists(this.api, testManagerLoginname);
|
||||
beforeEach(() => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureUserDoesntExist(ctx.api, testManagerUsername);
|
||||
ensureHumanUserExists(ctx.api, testManagerUsername);
|
||||
});
|
||||
});
|
||||
|
||||
describe('create authorization', () => {
|
||||
beforeEach(beforeCreate);
|
||||
beforeEach(navigate);
|
||||
beforeEach(() => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
beforeCreate(ctx);
|
||||
navigate();
|
||||
});
|
||||
});
|
||||
|
||||
it('should add a manager', () => {
|
||||
cy.get('[data-e2e="add-member-button"]').click();
|
||||
cy.get('[data-e2e="add-member-input"]').type(testManagerLoginname);
|
||||
cy.get('[data-e2e="add-member-input"]').type(testManagerUsername);
|
||||
cy.get('[data-e2e="user-option"]').first().click();
|
||||
cy.contains('[data-e2e="role-checkbox"]', roles[0]).click();
|
||||
cy.get('[data-e2e="confirm-add-member-button"]').click();
|
||||
@@ -45,14 +55,15 @@ describe('permissions', () => {
|
||||
});
|
||||
|
||||
describe('mutate authorization', () => {
|
||||
const rowSelector = `tr:contains(${testManagerLoginname})`;
|
||||
|
||||
beforeEach(beforeMutate);
|
||||
beforeEach(navigate);
|
||||
const rowSelector = `tr:contains(${testManagerUsername})`;
|
||||
|
||||
beforeEach(() => {
|
||||
cy.contains('[data-e2e="member-avatar"]', 'ee').click();
|
||||
cy.get(rowSelector).as('managerRow');
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
beforeMutate(ctx);
|
||||
navigate();
|
||||
cy.contains('[data-e2e="member-avatar"]', 'ee').click();
|
||||
cy.get(rowSelector).as('managerRow');
|
||||
});
|
||||
});
|
||||
|
||||
it('should remove a manager', () => {
|
||||
@@ -88,14 +99,14 @@ describe('permissions', () => {
|
||||
|
||||
testAuthorizations(
|
||||
roles.map((role) => role.display),
|
||||
function () {
|
||||
ensureHumanIsNotOrgMember(this.api, testManagerLoginname);
|
||||
function (ctx: Context) {
|
||||
ensureHumanIsNotOrgMember(ctx.api, testManagerUsername);
|
||||
},
|
||||
function () {
|
||||
ensureHumanIsNotOrgMember(this.api, testManagerLoginname);
|
||||
function (ctx: Context) {
|
||||
ensureHumanIsNotOrgMember(ctx.api, testManagerUsername);
|
||||
ensureHumanIsOrgMember(
|
||||
this.api,
|
||||
testManagerLoginname,
|
||||
ctx.api,
|
||||
testManagerUsername,
|
||||
roles.map((role) => role.internal),
|
||||
);
|
||||
},
|
||||
@@ -108,12 +119,16 @@ describe('permissions', () => {
|
||||
|
||||
describe('projects', () => {
|
||||
describe('owned projects', () => {
|
||||
beforeEach(function () {
|
||||
ensureProjectExists(this.api, 'e2eprojectpermission').as('projectId');
|
||||
beforeEach(() => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureProjectExists(ctx.api, 'e2eprojectpermission').as('projectId');
|
||||
});
|
||||
});
|
||||
|
||||
const visitOwnedProject: Mocha.HookFunction = function () {
|
||||
cy.visit(`/projects/${this.projectId}`);
|
||||
const visitOwnedProject = () => {
|
||||
cy.get<number>('@projectId').then((projectId) => {
|
||||
cy.visit(`/projects/${projectId}`);
|
||||
});
|
||||
};
|
||||
|
||||
describe('authorizations', () => {
|
||||
@@ -124,17 +139,21 @@ describe('permissions', () => {
|
||||
|
||||
testAuthorizations(
|
||||
roles.map((role) => role.display),
|
||||
function () {
|
||||
ensureHumanIsNotProjectMember(this.api, this.projectId, testManagerLoginname);
|
||||
function (ctx) {
|
||||
cy.get<string>('@projectId').then((projectId) => {
|
||||
ensureHumanIsNotProjectMember(ctx.api, projectId, testManagerUsername);
|
||||
});
|
||||
},
|
||||
function () {
|
||||
ensureHumanIsNotProjectMember(this.api, this.projectId, testManagerLoginname);
|
||||
ensureHumanIsProjectMember(
|
||||
this.api,
|
||||
this.projectId,
|
||||
testManagerLoginname,
|
||||
roles.map((role) => role.internal),
|
||||
);
|
||||
function (ctx) {
|
||||
cy.get<string>('@projectId').then((projectId) => {
|
||||
ensureHumanIsNotProjectMember(ctx.api, projectId, testManagerUsername);
|
||||
ensureHumanIsProjectMember(
|
||||
ctx.api,
|
||||
projectId,
|
||||
testManagerUsername,
|
||||
roles.map((role) => role.internal),
|
||||
);
|
||||
});
|
||||
},
|
||||
visitOwnedProject,
|
||||
);
|
||||
@@ -143,12 +162,15 @@ describe('permissions', () => {
|
||||
describe('roles', () => {
|
||||
const testRoleName = 'e2eroleundertestname';
|
||||
|
||||
beforeEach(function () {
|
||||
ensureProjectResourceDoesntExist(this.api, this.projectId, Roles, testRoleName);
|
||||
beforeEach(() => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
cy.get<string>('@projectId').then((projectId) => {
|
||||
ensureProjectResourceDoesntExist(ctx.api, projectId, Roles, testRoleName);
|
||||
visitOwnedProject();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(visitOwnedProject);
|
||||
|
||||
it('should add a role', () => {
|
||||
cy.get('[data-e2e="sidenav-element-roles"]').click();
|
||||
cy.get('[data-e2e="add-new-role"]').click();
|
||||
@@ -164,21 +186,25 @@ describe('permissions', () => {
|
||||
});
|
||||
|
||||
describe('granted projects', () => {
|
||||
beforeEach(function () {
|
||||
ensureOrgExists(this.api, 'e2eforeignorg')
|
||||
.as('foreignOrgId')
|
||||
.then((foreignOrgId) => {
|
||||
ensureProjectExists(this.api, 'e2eprojectgrants', foreignOrgId)
|
||||
.as('projectId')
|
||||
.then((projectId) => {
|
||||
ensureProjectGrantExists(this.api, foreignOrgId, projectId).as('grantId');
|
||||
beforeEach(() => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureOrgExists(ctx, 'e2eforeignorg').then((foreignOrgId) => {
|
||||
ensureProjectExists(ctx.api, 'e2eprojectgrants', foreignOrgId)
|
||||
.as('foreignProjectId')
|
||||
.then((foreignProjectId) => {
|
||||
ensureProjectGrantExists(ctx, foreignOrgId, foreignProjectId).as('grantId');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const visitGrantedProject: Mocha.HookFunction = function () {
|
||||
cy.visit(`/granted-projects/${this.projectId}/grant/${this.grantId}`);
|
||||
};
|
||||
function visitGrantedProject() {
|
||||
cy.get<string>('@foreignProjectId').then((foreignProjectId) => {
|
||||
cy.get<string>('@grantId').then((grantId) => {
|
||||
cy.visit(`/granted-projects/${foreignProjectId}/grant/${grantId}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe('authorizations', () => {
|
||||
const roles = [
|
||||
@@ -188,18 +214,26 @@ describe('permissions', () => {
|
||||
|
||||
testAuthorizations(
|
||||
roles.map((role) => role.display),
|
||||
function () {
|
||||
ensureHumanIsNotProjectMember(this.api, this.projectId, testManagerLoginname, this.grantId);
|
||||
function (ctx: Context) {
|
||||
cy.get<string>('@foreignProjectId').then((foreignProjectId) => {
|
||||
cy.get<string>('@grantId').then((grantId) => {
|
||||
ensureHumanIsNotProjectMember(ctx.api, foreignProjectId, testManagerUsername, grantId);
|
||||
});
|
||||
});
|
||||
},
|
||||
function () {
|
||||
ensureHumanIsNotProjectMember(this.api, this.projectId, testManagerLoginname, this.grantId);
|
||||
ensureHumanIsProjectMember(
|
||||
this.api,
|
||||
this.projectId,
|
||||
testManagerLoginname,
|
||||
roles.map((role) => role.internal),
|
||||
this.grantId,
|
||||
);
|
||||
function (ctx: Context) {
|
||||
cy.get<string>('@foreignProjectId').then((foreignProjectId) => {
|
||||
cy.get<string>('@grantId').then((grantId) => {
|
||||
ensureHumanIsNotProjectMember(ctx.api, foreignProjectId, testManagerUsername, grantId);
|
||||
ensureHumanIsProjectMember(
|
||||
ctx.api,
|
||||
foreignProjectId,
|
||||
testManagerUsername,
|
||||
roles.map((role) => role.internal),
|
||||
grantId,
|
||||
);
|
||||
});
|
||||
});
|
||||
},
|
||||
visitGrantedProject,
|
||||
);
|
||||
@@ -207,42 +241,42 @@ describe('permissions', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('validations', () => {
|
||||
describe('owned projects', () => {
|
||||
describe('no ownership', () => {
|
||||
it('a user without project global ownership can ...');
|
||||
it('a user without project global ownership can not ...');
|
||||
});
|
||||
describe('project owner viewer global', () => {
|
||||
it('a project owner viewer global additionally can ...');
|
||||
it('a project owner viewer global still can not ...');
|
||||
});
|
||||
describe('project owner global', () => {
|
||||
it('a project owner global additionally can ...');
|
||||
it('a project owner global still can not ...');
|
||||
});
|
||||
describe('validations', () => {
|
||||
describe('owned projects', () => {
|
||||
describe('no ownership', () => {
|
||||
it('a user without project global ownership can ...');
|
||||
it('a user without project global ownership can not ...');
|
||||
});
|
||||
describe('project owner viewer global', () => {
|
||||
it('a project owner viewer global additionally can ...');
|
||||
it('a project owner viewer global still can not ...');
|
||||
});
|
||||
describe('project owner global', () => {
|
||||
it('a project owner global additionally can ...');
|
||||
it('a project owner global still can not ...');
|
||||
});
|
||||
});
|
||||
|
||||
describe('granted projects', () => {
|
||||
describe('no ownership', () => {
|
||||
it('a user without project grant ownership can ...');
|
||||
it('a user without project grant ownership can not ...');
|
||||
});
|
||||
describe('project grant owner viewer', () => {
|
||||
it('a project grant owner viewer additionally can ...');
|
||||
it('a project grant owner viewer still can not ...');
|
||||
});
|
||||
describe('project grant owner', () => {
|
||||
it('a project grant owner additionally can ...');
|
||||
it('a project grant owner still can not ...');
|
||||
});
|
||||
describe('granted projects', () => {
|
||||
describe('no ownership', () => {
|
||||
it('a user without project grant ownership can ...');
|
||||
it('a user without project grant ownership can not ...');
|
||||
});
|
||||
describe('organization', () => {
|
||||
describe('org owner', () => {
|
||||
it('a project owner global can ...');
|
||||
it('a project owner global can not ...');
|
||||
});
|
||||
describe('project grant owner viewer', () => {
|
||||
it('a project grant owner viewer additionally can ...');
|
||||
it('a project grant owner viewer still can not ...');
|
||||
});
|
||||
describe('project grant owner', () => {
|
||||
it('a project grant owner additionally can ...');
|
||||
it('a project grant owner still can not ...');
|
||||
});
|
||||
});
|
||||
describe('organization', () => {
|
||||
describe('org owner', () => {
|
||||
it('a project owner global can ...');
|
||||
it('a project owner global can not ...');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,18 +1,20 @@
|
||||
import { apiAuth } from '../../support/api/apiauth';
|
||||
import { Context } from 'support/commands';
|
||||
import { ensureProjectDoesntExist, ensureProjectExists } from '../../support/api/projects';
|
||||
|
||||
describe('projects', () => {
|
||||
beforeEach(() => {
|
||||
apiAuth().as('api');
|
||||
cy.context().as('ctx');
|
||||
});
|
||||
|
||||
const testProjectNameCreate = 'e2eprojectcreate';
|
||||
const testProjectNameDelete = 'e2eprojectdelete';
|
||||
|
||||
describe('add project', () => {
|
||||
beforeEach(`ensure it doesn't exist already`, function () {
|
||||
ensureProjectDoesntExist(this.api, testProjectNameCreate);
|
||||
cy.visit(`/projects`);
|
||||
beforeEach(`ensure it doesn't exist already`, () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureProjectDoesntExist(ctx.api, testProjectNameCreate);
|
||||
cy.visit(`/projects`);
|
||||
});
|
||||
});
|
||||
|
||||
it('should add a project', () => {
|
||||
@@ -26,9 +28,11 @@ describe('projects', () => {
|
||||
});
|
||||
|
||||
describe('edit project', () => {
|
||||
beforeEach('ensure it exists', function () {
|
||||
ensureProjectExists(this.api, testProjectNameDelete);
|
||||
cy.visit(`/projects`);
|
||||
beforeEach('ensure it exists', () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureProjectExists(ctx.api, testProjectNameDelete);
|
||||
cy.visit(`/projects`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('remove project', () => {
|
||||
|
248
e2e/cypress/e2e/quotas/quotas.cy.ts
Normal file
248
e2e/cypress/e2e/quotas/quotas.cy.ts
Normal file
@@ -0,0 +1,248 @@
|
||||
import { addQuota, ensureQuotaIsAdded, ensureQuotaIsRemoved, removeQuota, Unit } from 'support/api/quota';
|
||||
import { createHumanUser, ensureUserDoesntExist } from 'support/api/users';
|
||||
import { Context } from 'support/commands';
|
||||
import { ZITADELWebhookEvent } from 'support/types';
|
||||
|
||||
beforeEach(() => {
|
||||
cy.context().as('ctx');
|
||||
});
|
||||
|
||||
describe('quotas', () => {
|
||||
describe('management', () => {
|
||||
describe('add one quota', () => {
|
||||
it('should add a quota only once per unit', () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
addQuota(ctx, Unit.AuthenticatedRequests, true, 1);
|
||||
addQuota(ctx, Unit.AuthenticatedRequests, true, 1, undefined, undefined, undefined, false).then((res) => {
|
||||
expect(res.status).to.equal(409);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('add two quotas', () => {
|
||||
it('should add a quota for each unit', () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
addQuota(ctx, Unit.AuthenticatedRequests, true, 1);
|
||||
addQuota(ctx, Unit.ExecutionSeconds, true, 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('edit', () => {
|
||||
describe('remove one quota', () => {
|
||||
beforeEach(() => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureQuotaIsAdded(ctx, Unit.AuthenticatedRequests, true, 1);
|
||||
});
|
||||
});
|
||||
it('should remove a quota only once per unit', () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
removeQuota(ctx, Unit.AuthenticatedRequests);
|
||||
});
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
removeQuota(ctx, Unit.AuthenticatedRequests, false).then((res) => {
|
||||
expect(res.status).to.equal(404);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('remove two quotas', () => {
|
||||
beforeEach(() => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureQuotaIsAdded(ctx, Unit.AuthenticatedRequests, true, 1);
|
||||
ensureQuotaIsAdded(ctx, Unit.ExecutionSeconds, true, 1);
|
||||
});
|
||||
});
|
||||
it('should remove a quota for each unit', () => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
removeQuota(ctx, Unit.AuthenticatedRequests);
|
||||
removeQuota(ctx, Unit.ExecutionSeconds);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('usage', () => {
|
||||
beforeEach(() => {
|
||||
cy.get<Context>('@ctx')
|
||||
.then((ctx) => {
|
||||
return [
|
||||
`${ctx.api.oidcBaseURL}/userinfo`,
|
||||
`${ctx.api.authBaseURL}/users/me`,
|
||||
`${ctx.api.mgmtBaseURL}/iam`,
|
||||
`${ctx.api.adminBaseURL}/instances/me`,
|
||||
`${ctx.api.oauthBaseURL}/keys`,
|
||||
`${ctx.api.samlBaseURL}/certificate`,
|
||||
];
|
||||
})
|
||||
.as('authenticatedUrls');
|
||||
});
|
||||
|
||||
describe('authenticated requests', () => {
|
||||
const testUserName = 'shouldNotBeCreated';
|
||||
beforeEach(() => {
|
||||
cy.get<Array<string>>('@authenticatedUrls').then((urls) => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureUserDoesntExist(ctx.api, testUserName);
|
||||
ensureQuotaIsAdded(ctx, Unit.AuthenticatedRequests, true, urls.length);
|
||||
cy.task('runSQL', `TRUNCATE logstore.access;`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('authenticated requests are limited', () => {
|
||||
cy.get<Array<string>>('@authenticatedUrls').then((urls) => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
const start = new Date();
|
||||
urls.forEach((url) => {
|
||||
cy.request({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
auth: {
|
||||
bearer: ctx.api.token,
|
||||
},
|
||||
});
|
||||
});
|
||||
const expiresMax = new Date();
|
||||
expiresMax.setMinutes(expiresMax.getMinutes() + 2);
|
||||
cy.getCookie('zitadel.quota.limiting').then((cookie) => {
|
||||
expect(cookie.value).to.equal('false');
|
||||
const cookieExpiry = new Date();
|
||||
cookieExpiry.setTime(cookie.expiry * 1000);
|
||||
expect(cookieExpiry).to.be.within(start, expiresMax);
|
||||
});
|
||||
cy.request({
|
||||
url: urls[0],
|
||||
method: 'GET',
|
||||
auth: {
|
||||
bearer: ctx.api.token,
|
||||
},
|
||||
failOnStatusCode: false,
|
||||
}).then((res) => {
|
||||
expect(res.status).to.equal(429);
|
||||
});
|
||||
cy.getCookie('zitadel.quota.limiting').then((cookie) => {
|
||||
expect(cookie.value).to.equal('true');
|
||||
});
|
||||
createHumanUser(ctx.api, testUserName, false).then((res) => {
|
||||
expect(res.status).to.equal(429);
|
||||
});
|
||||
ensureQuotaIsRemoved(ctx, Unit.AuthenticatedRequests);
|
||||
createHumanUser(ctx.api, testUserName);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('notifications', () => {
|
||||
const callURL = `http://${Cypress.env('WEBHOOK_HANDLER_HOST')}:${Cypress.env('WEBHOOK_HANDLER_PORT')}/do_something`;
|
||||
|
||||
beforeEach(() => cy.task('resetWebhookEvents'));
|
||||
|
||||
const amount = 100;
|
||||
const percent = 10;
|
||||
const usage = 25;
|
||||
|
||||
describe('without repetition', () => {
|
||||
beforeEach(() => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureQuotaIsAdded(ctx, Unit.AuthenticatedRequests, false, amount, [
|
||||
{
|
||||
callUrl: callURL,
|
||||
percent: percent,
|
||||
repeat: false,
|
||||
},
|
||||
]);
|
||||
cy.task('runSQL', `TRUNCATE logstore.access;`);
|
||||
});
|
||||
});
|
||||
|
||||
it('fires once with the expected payload', () => {
|
||||
cy.get<Array<string>>('@authenticatedUrls').then((urls) => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
for (let i = 0; i < usage; i++) {
|
||||
cy.request({
|
||||
url: urls[0],
|
||||
method: 'GET',
|
||||
auth: {
|
||||
bearer: ctx.api.token,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
cy.waitUntil(() =>
|
||||
cy.task<Array<ZITADELWebhookEvent>>('handledWebhookEvents').then((events) => {
|
||||
if (events.length != 1) {
|
||||
return false;
|
||||
}
|
||||
return Cypress._.matches(<ZITADELWebhookEvent>{
|
||||
callURL: callURL,
|
||||
threshold: percent,
|
||||
unit: 1,
|
||||
usage: percent,
|
||||
})(events[0]);
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('with repetition', () => {
|
||||
beforeEach(() => {
|
||||
cy.get<Array<string>>('@authenticatedUrls').then((urls) => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
ensureQuotaIsAdded(ctx, Unit.AuthenticatedRequests, false, amount, [
|
||||
{
|
||||
callUrl: callURL,
|
||||
percent: percent,
|
||||
repeat: true,
|
||||
},
|
||||
]);
|
||||
cy.task('runSQL', `TRUNCATE logstore.access;`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('fires repeatedly with the expected payloads', () => {
|
||||
cy.get<Array<string>>('@authenticatedUrls').then((urls) => {
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
for (let i = 0; i < usage; i++) {
|
||||
cy.request({
|
||||
url: urls[0],
|
||||
method: 'GET',
|
||||
auth: {
|
||||
bearer: ctx.api.token,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
cy.waitUntil(() =>
|
||||
cy.task<Array<ZITADELWebhookEvent>>('handledWebhookEvents').then((events) => {
|
||||
if (events.length != 1) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < events.length; i++) {
|
||||
const threshold = percent * (i + 1);
|
||||
if (
|
||||
!Cypress._.matches(<ZITADELWebhookEvent>{
|
||||
callURL: callURL,
|
||||
threshold: threshold,
|
||||
unit: 1,
|
||||
usage: threshold,
|
||||
})(events[i])
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@@ -1,4 +1,5 @@
|
||||
import { apiAuth, API } from '../../support/api/apiauth';
|
||||
import { Context } from 'mocha';
|
||||
import { apiAuth } from '../../support/api/apiauth';
|
||||
import { Policy, resetPolicy } from '../../support/api/policies';
|
||||
import { login, User } from '../../support/login/users';
|
||||
|
||||
@@ -7,8 +8,6 @@ describe('private labeling', () => {
|
||||
|
||||
[User.OrgOwner].forEach((user) => {
|
||||
describe(`as user "${user}"`, () => {
|
||||
let api: API;
|
||||
|
||||
beforeEach(() => {
|
||||
login(user);
|
||||
cy.visit(orgPath);
|
||||
@@ -37,34 +36,27 @@ function customize(theme: string, user: User) {
|
||||
});
|
||||
|
||||
it('should update a logo', () => {
|
||||
cy.get('[data-e2e="image-part-logo"]')
|
||||
.find('input')
|
||||
.then(function (el) {
|
||||
const blob = Cypress.Blob.base64StringToBlob(this.logo, 'image/png');
|
||||
const file = new File([blob], 'images/logo.png', { type: 'image/png' });
|
||||
const list = new DataTransfer();
|
||||
cy.get<Context>('@ctx').then((ctx) => {
|
||||
cy.get('[data-e2e="image-part-logo"]')
|
||||
.find('input')
|
||||
.then(function (el) {
|
||||
const blob = Cypress.Blob.base64StringToBlob(ctx.logo, 'image/png');
|
||||
const file = new File([blob], 'images/logo.png', { type: 'image/png' });
|
||||
const list = new DataTransfer();
|
||||
|
||||
list.items.add(file);
|
||||
const myFileList = list.files;
|
||||
list.items.add(file);
|
||||
const myFileList = list.files;
|
||||
|
||||
el[0].files = myFileList;
|
||||
el[0].dispatchEvent(new Event('change', { bubbles: true }));
|
||||
});
|
||||
el[0].files = myFileList;
|
||||
el[0].dispatchEvent(new Event('change', { bubbles: true }));
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should delete a logo');
|
||||
});
|
||||
it('should update an icon');
|
||||
it('should delete an icon');
|
||||
it.skip('should update the background color', () => {
|
||||
cy.contains('[data-e2e="color"]', 'Background Color').find('button').click(); // TODO: select data-e2e
|
||||
cy.get('color-editable-input').find('input').clear().type('#ae44dc');
|
||||
cy.get('[data-e2e="save-colors-button"]').click();
|
||||
cy.get('[data-e2e="header-user-avatar"]').click();
|
||||
cy.contains('Logout All Users').click(); // TODO: select data-e2e
|
||||
login(User.LoginPolicyUser, undefined, true, null, () => {
|
||||
cy.pause();
|
||||
});
|
||||
});
|
||||
it('should update the background color');
|
||||
it('should update the primary color');
|
||||
it('should update the warning color');
|
||||
it('should update the font color');
|
||||
|
@@ -1,21 +1,36 @@
|
||||
import { login, User } from 'support/login/users';
|
||||
import { API } from './types';
|
||||
import { API, SystemAPI, Token } from './types';
|
||||
|
||||
const authHeaderKey = 'Authorization',
|
||||
orgIdHeaderKey = 'x-zitadel-orgid';
|
||||
orgIdHeaderKey = 'x-zitadel-orgid',
|
||||
backendUrl = Cypress.env('BACKEND_URL');
|
||||
|
||||
export function apiAuth(): Cypress.Chainable<API> {
|
||||
return login(User.IAMAdminUser, 'Password1!', false, true).then((token) => {
|
||||
return <API>{
|
||||
token: token,
|
||||
mgmtBaseURL: `${Cypress.env('BACKEND_URL')}/management/v1`,
|
||||
adminBaseURL: `${Cypress.env('BACKEND_URL')}/admin/v1`,
|
||||
mgmtBaseURL: `${backendUrl}/management/v1`,
|
||||
adminBaseURL: `${backendUrl}/admin/v1`,
|
||||
authBaseURL: `${backendUrl}/auth/v1`,
|
||||
assetsBaseURL: `${backendUrl}/assets/v1`,
|
||||
oauthBaseURL: `${backendUrl}/oauth/v2`,
|
||||
oidcBaseURL: `${backendUrl}/oidc/v1`,
|
||||
samlBaseURL: `${backendUrl}/saml/v2`,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function requestHeaders(api: API, orgId?: number): object {
|
||||
const headers = { [authHeaderKey]: `Bearer ${api.token}` };
|
||||
export function systemAuth(): Cypress.Chainable<SystemAPI> {
|
||||
return cy.task('systemToken').then((token) => {
|
||||
return <SystemAPI>{
|
||||
token: token,
|
||||
baseURL: `${backendUrl}/system/v1`,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function requestHeaders(token: Token, orgId?: string): object {
|
||||
const headers = { [authHeaderKey]: `Bearer ${token.token}` };
|
||||
if (orgId) {
|
||||
headers[orgIdHeaderKey] = orgId;
|
||||
}
|
||||
|
@@ -1,20 +1,20 @@
|
||||
import { requestHeaders } from './apiauth';
|
||||
import { findFromList as mapFromList, searchSomething } from './search';
|
||||
import { API, Entity, SearchResult } from './types';
|
||||
import { API, Entity, SearchResult, Token } from './types';
|
||||
|
||||
export function ensureItemExists(
|
||||
api: API,
|
||||
token: Token,
|
||||
searchPath: string,
|
||||
findInList: (entity: Entity) => boolean,
|
||||
createPath: string,
|
||||
body: Entity,
|
||||
orgId?: number,
|
||||
orgId?: string,
|
||||
newItemIdField: string = 'id',
|
||||
searchItemIdField?: string,
|
||||
): Cypress.Chainable<number> {
|
||||
) {
|
||||
return ensureSomething(
|
||||
api,
|
||||
() => searchSomething(api, searchPath, 'POST', mapFromList(findInList, searchItemIdField), orgId),
|
||||
token,
|
||||
() => searchSomething(token, searchPath, 'POST', mapFromList(findInList, searchItemIdField), orgId),
|
||||
() => createPath,
|
||||
'POST',
|
||||
body,
|
||||
@@ -25,15 +25,15 @@ export function ensureItemExists(
|
||||
}
|
||||
|
||||
export function ensureItemDoesntExist(
|
||||
api: API,
|
||||
token: Token,
|
||||
searchPath: string,
|
||||
findInList: (entity: Entity) => boolean,
|
||||
deletePath: (entity: Entity) => string,
|
||||
orgId?: number,
|
||||
orgId?: string,
|
||||
): Cypress.Chainable<null> {
|
||||
return ensureSomething(
|
||||
api,
|
||||
() => searchSomething(api, searchPath, 'POST', mapFromList(findInList), orgId),
|
||||
token,
|
||||
() => searchSomething(token, searchPath, 'POST', mapFromList(findInList), orgId),
|
||||
deletePath,
|
||||
'DELETE',
|
||||
null,
|
||||
@@ -47,8 +47,8 @@ export function ensureSetting(
|
||||
mapResult: (entity: any) => SearchResult,
|
||||
createPath: string,
|
||||
body: any,
|
||||
orgId?: number,
|
||||
): Cypress.Chainable<number> {
|
||||
orgId?: string,
|
||||
): Cypress.Chainable<string> {
|
||||
return ensureSomething(
|
||||
api,
|
||||
() => searchSomething(api, path, 'GET', mapResult, orgId),
|
||||
@@ -79,38 +79,38 @@ function awaitDesired(
|
||||
}
|
||||
|
||||
interface EnsuredResult {
|
||||
id: number;
|
||||
id: string;
|
||||
sequence: number;
|
||||
}
|
||||
|
||||
export function ensureSomething(
|
||||
api: API,
|
||||
token: Token,
|
||||
search: () => Cypress.Chainable<SearchResult>,
|
||||
apiPath: (entity: Entity) => string,
|
||||
ensureMethod: string,
|
||||
body: Entity,
|
||||
expectEntity: (entity: Entity) => boolean,
|
||||
mapId?: (body: any) => number,
|
||||
orgId?: number,
|
||||
): Cypress.Chainable<number> {
|
||||
mapId?: (body: any) => string,
|
||||
orgId?: string,
|
||||
): Cypress.Chainable<string> {
|
||||
return search()
|
||||
.then<EnsuredResult>((sRes) => {
|
||||
.then((sRes) => {
|
||||
if (expectEntity(sRes.entity)) {
|
||||
return cy.wrap({ id: sRes.id, sequence: sRes.sequence });
|
||||
return cy.wrap(<EnsuredResult>{ id: sRes.id, sequence: sRes.sequence });
|
||||
}
|
||||
|
||||
return cy
|
||||
.request({
|
||||
method: ensureMethod,
|
||||
url: apiPath(sRes.entity),
|
||||
headers: requestHeaders(api, orgId),
|
||||
headers: requestHeaders(token, orgId),
|
||||
body: body,
|
||||
failOnStatusCode: false,
|
||||
followRedirect: false,
|
||||
})
|
||||
.then((cRes) => {
|
||||
expect(cRes.status).to.equal(200);
|
||||
return {
|
||||
return <EnsuredResult>{
|
||||
id: mapId ? mapId(cRes.body) : undefined,
|
||||
sequence: sRes.sequence,
|
||||
};
|
||||
@@ -118,7 +118,7 @@ export function ensureSomething(
|
||||
})
|
||||
.then((data) => {
|
||||
return awaitDesired(90, expectEntity, search, data.sequence).then(() => {
|
||||
return cy.wrap<number>(data.id);
|
||||
return cy.wrap(data.id);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -1,18 +1,14 @@
|
||||
import { Context } from 'support/commands';
|
||||
import { ensureItemExists } from './ensure';
|
||||
import { getOrgUnderTest } from './orgs';
|
||||
import { API } from './types';
|
||||
|
||||
export function ensureProjectGrantExists(
|
||||
api: API,
|
||||
foreignOrgId: number,
|
||||
foreignProjectId: number,
|
||||
): Cypress.Chainable<number> {
|
||||
return getOrgUnderTest(api).then((orgUnderTest) => {
|
||||
export function ensureProjectGrantExists(ctx: Context, foreignOrgId: string, foreignProjectId: string) {
|
||||
return getOrgUnderTest(ctx).then((orgUnderTest) => {
|
||||
return ensureItemExists(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/projectgrants/_search`,
|
||||
ctx.api,
|
||||
`${ctx.api.mgmtBaseURL}/projectgrants/_search`,
|
||||
(grant: any) => grant.grantedOrgId == orgUnderTest && grant.projectId == foreignProjectId,
|
||||
`${api.mgmtBaseURL}/projects/${foreignProjectId}/grants`,
|
||||
`${ctx.api.mgmtBaseURL}/projects/${foreignProjectId}/grants`,
|
||||
{ granted_org_id: orgUnderTest },
|
||||
foreignOrgId,
|
||||
'grantId',
|
||||
|
31
e2e/cypress/support/api/instances.ts
Normal file
31
e2e/cypress/support/api/instances.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { SystemAPI } from './types';
|
||||
|
||||
export function instanceUnderTest(api: SystemAPI): Cypress.Chainable<string> {
|
||||
return cy
|
||||
.request({
|
||||
method: 'POST',
|
||||
url: `${api.baseURL}/instances/_search`,
|
||||
auth: {
|
||||
bearer: api.token,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
const instances = <Array<any>>res.body.result;
|
||||
expect(instances.length).to.equal(
|
||||
1,
|
||||
'instanceUnderTest just supports running against an API with exactly one instance, yet',
|
||||
);
|
||||
return instances[0].id;
|
||||
});
|
||||
}
|
||||
|
||||
export function getInstance(api: SystemAPI, instanceId: string, failOnStatusCode = true) {
|
||||
return cy.request({
|
||||
method: 'GET',
|
||||
url: `${api.baseURL}/instances/${instanceId}`,
|
||||
auth: {
|
||||
bearer: api.token,
|
||||
},
|
||||
failOnStatusCode: failOnStatusCode,
|
||||
});
|
||||
}
|
@@ -2,7 +2,7 @@ import { ensureItemDoesntExist, ensureItemExists } from './ensure';
|
||||
import { findFromList, searchSomething } from './search';
|
||||
import { API } from './types';
|
||||
|
||||
export function ensureHumanIsNotOrgMember(api: API, username: string): Cypress.Chainable<number> {
|
||||
export function ensureHumanIsNotOrgMember(api: API, username: string) {
|
||||
return ensureItemDoesntExist(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/orgs/me/members/_search`,
|
||||
@@ -11,7 +11,7 @@ export function ensureHumanIsNotOrgMember(api: API, username: string): Cypress.C
|
||||
);
|
||||
}
|
||||
|
||||
export function ensureHumanIsOrgMember(api: API, username: string, roles: string[]): Cypress.Chainable<number> {
|
||||
export function ensureHumanIsOrgMember(api: API, username: string, roles: string[]) {
|
||||
return searchSomething(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/users/_search`,
|
||||
@@ -37,13 +37,13 @@ export function ensureHumanIsNotProjectMember(
|
||||
api: API,
|
||||
projectId: string,
|
||||
username: string,
|
||||
grantId?: number,
|
||||
): Cypress.Chainable<number> {
|
||||
grantId?: string,
|
||||
): Cypress.Chainable<string> {
|
||||
return ensureItemDoesntExist(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/projects/${projectId}/${grantId ? `grants/${grantId}/` : ''}members/_search`,
|
||||
(member: any) => (<string>member.preferredLoginName).startsWith(username),
|
||||
(member) => `${api.mgmtBaseURL}/projects/${projectId}${grantId ? `grants/${grantId}/` : ''}/members/${member.userId}`,
|
||||
(member) => `${api.mgmtBaseURL}/projects/${projectId}/${grantId ? `grants/${grantId}/` : ''}members/${member.userId}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ export function ensureHumanIsProjectMember(
|
||||
projectId: string,
|
||||
username: string,
|
||||
roles: string[],
|
||||
grantId?: number,
|
||||
): Cypress.Chainable<number> {
|
||||
grantId?: string,
|
||||
): Cypress.Chainable<string> {
|
||||
return searchSomething(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/users/_search`,
|
||||
|
@@ -7,7 +7,7 @@ export function ensureOIDCSettingsSet(
|
||||
idTokenLifetime: number,
|
||||
refreshTokenExpiration: number,
|
||||
refreshTokenIdleExpiration: number,
|
||||
): Cypress.Chainable<number> {
|
||||
) {
|
||||
return ensureSetting(
|
||||
api,
|
||||
`${api.adminBaseURL}/settings/oidc`,
|
||||
|
@@ -3,20 +3,21 @@ import { searchSomething } from './search';
|
||||
import { API } from './types';
|
||||
import { host } from '../login/users';
|
||||
import { requestHeaders } from './apiauth';
|
||||
import { Context } from 'support/commands';
|
||||
|
||||
export function ensureOrgExists(api: API, name: string): Cypress.Chainable<number> {
|
||||
export function ensureOrgExists(ctx: Context, name: string) {
|
||||
return ensureSomething(
|
||||
api,
|
||||
ctx.api,
|
||||
() =>
|
||||
searchSomething(
|
||||
api,
|
||||
encodeURI(`${api.mgmtBaseURL}/global/orgs/_by_domain?domain=${name}.${host(Cypress.config('baseUrl'))}`),
|
||||
ctx.api,
|
||||
encodeURI(`${ctx.api.mgmtBaseURL}/global/orgs/_by_domain?domain=${name}.${host(Cypress.config('baseUrl'))}`),
|
||||
'GET',
|
||||
(res) => {
|
||||
return { entity: res.org, id: res.org?.id, sequence: parseInt(<string>res.org?.details?.sequence) };
|
||||
},
|
||||
),
|
||||
() => `${api.mgmtBaseURL}/orgs`,
|
||||
() => `${ctx.api.mgmtBaseURL}/orgs`,
|
||||
'POST',
|
||||
{ name: name },
|
||||
(org) => org?.name === name,
|
||||
@@ -24,13 +25,13 @@ export function ensureOrgExists(api: API, name: string): Cypress.Chainable<numbe
|
||||
);
|
||||
}
|
||||
|
||||
export function isDefaultOrg(api: API, orgId: number): Cypress.Chainable<boolean> {
|
||||
export function isDefaultOrg(ctx: Context, orgId: string): Cypress.Chainable<boolean> {
|
||||
console.log('huhu', orgId);
|
||||
return cy
|
||||
.request({
|
||||
method: 'GET',
|
||||
url: encodeURI(`${api.mgmtBaseURL}/iam`),
|
||||
headers: requestHeaders(api, orgId),
|
||||
url: encodeURI(`${ctx.api.mgmtBaseURL}/iam`),
|
||||
headers: requestHeaders(ctx.api, orgId),
|
||||
})
|
||||
.then((res) => {
|
||||
const { defaultOrgId } = res.body;
|
||||
@@ -39,12 +40,12 @@ export function isDefaultOrg(api: API, orgId: number): Cypress.Chainable<boolean
|
||||
});
|
||||
}
|
||||
|
||||
export function ensureOrgIsDefault(api: API, orgId: number): Cypress.Chainable<boolean> {
|
||||
export function ensureOrgIsDefault(ctx: Context, orgId: string): Cypress.Chainable<boolean> {
|
||||
return cy
|
||||
.request({
|
||||
method: 'GET',
|
||||
url: encodeURI(`${api.mgmtBaseURL}/iam`),
|
||||
headers: requestHeaders(api, orgId),
|
||||
url: encodeURI(`${ctx.api.mgmtBaseURL}/iam`),
|
||||
headers: requestHeaders(ctx.api, orgId),
|
||||
})
|
||||
.then((res) => {
|
||||
return res.body;
|
||||
@@ -56,8 +57,8 @@ export function ensureOrgIsDefault(api: API, orgId: number): Cypress.Chainable<b
|
||||
return cy
|
||||
.request({
|
||||
method: 'PUT',
|
||||
url: `${api.adminBaseURL}/orgs/default/${orgId}`,
|
||||
headers: requestHeaders(api, orgId),
|
||||
url: `${ctx.api.adminBaseURL}/orgs/default/${orgId}`,
|
||||
headers: requestHeaders(ctx.api, orgId),
|
||||
failOnStatusCode: true,
|
||||
followRedirect: false,
|
||||
})
|
||||
@@ -69,8 +70,8 @@ export function ensureOrgIsDefault(api: API, orgId: number): Cypress.Chainable<b
|
||||
});
|
||||
}
|
||||
|
||||
export function getOrgUnderTest(api: API): Cypress.Chainable<number> {
|
||||
return searchSomething(api, `${api.mgmtBaseURL}/orgs/me`, 'GET', (res) => {
|
||||
export function getOrgUnderTest(ctx: Context): Cypress.Chainable<number> {
|
||||
return searchSomething(ctx.api, `${ctx.api.mgmtBaseURL}/orgs/me`, 'GET', (res) => {
|
||||
return { entity: res.org, id: res.org.id, sequence: parseInt(<string>res.org.details.sequence) };
|
||||
}).then((res) => res.entity.id);
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ export function ensureDomainPolicy(
|
||||
userLoginMustBeDomain: boolean,
|
||||
validateOrgDomains: boolean,
|
||||
smtpSenderAddressMatchesInstanceDomain: boolean,
|
||||
): Cypress.Chainable<number> {
|
||||
) {
|
||||
return ensureSetting(
|
||||
api,
|
||||
`${api.adminBaseURL}/policies/domain`,
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { ensureItemDoesntExist, ensureItemExists } from './ensure';
|
||||
import { API } from './types';
|
||||
import { API, Entity } from './types';
|
||||
|
||||
export function ensureProjectExists(api: API, projectName: string, orgId?: number): Cypress.Chainable<number> {
|
||||
export function ensureProjectExists(api: API, projectName: string, orgId?: string) {
|
||||
return ensureItemExists(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/projects/_search`,
|
||||
@@ -12,7 +12,7 @@ export function ensureProjectExists(api: API, projectName: string, orgId?: numbe
|
||||
);
|
||||
}
|
||||
|
||||
export function ensureProjectDoesntExist(api: API, projectName: string, orgId?: number): Cypress.Chainable<null> {
|
||||
export function ensureProjectDoesntExist(api: API, projectName: string, orgId?: string) {
|
||||
return ensureItemDoesntExist(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/projects/_search`,
|
||||
@@ -32,22 +32,22 @@ export const Roles = new ResourceType('roles', 'key', 'key');
|
||||
|
||||
export function ensureProjectResourceDoesntExist(
|
||||
api: API,
|
||||
projectId: number,
|
||||
projectId: string,
|
||||
resourceType: ResourceType,
|
||||
resourceName: string,
|
||||
orgId?: number,
|
||||
orgId?: string,
|
||||
): Cypress.Chainable<null> {
|
||||
return ensureItemDoesntExist(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/projects/${projectId}/${resourceType.resourcePath}/_search`,
|
||||
(resource: any) => resource[resourceType.compareProperty] === resourceName,
|
||||
(resource) =>
|
||||
(resource: Entity) => resource[resourceType.compareProperty] === resourceName,
|
||||
(resource: Entity) =>
|
||||
`${api.mgmtBaseURL}/projects/${projectId}/${resourceType.resourcePath}/${resource[resourceType.identifierProperty]}`,
|
||||
orgId,
|
||||
);
|
||||
}
|
||||
|
||||
export function ensureApplicationExists(api: API, projectId: number, appName: string): Cypress.Chainable<number> {
|
||||
export function ensureApplicationExists(api: API, projectId: number, appName: string) {
|
||||
return ensureItemExists(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/projects/${projectId}/${Apps.resourcePath}/_search`,
|
||||
|
84
e2e/cypress/support/api/quota.ts
Normal file
84
e2e/cypress/support/api/quota.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import { Context } from 'support/commands';
|
||||
|
||||
export enum Unit {
|
||||
Unimplemented,
|
||||
AuthenticatedRequests,
|
||||
ExecutionSeconds,
|
||||
}
|
||||
|
||||
interface notification {
|
||||
percent: number;
|
||||
repeat?: boolean;
|
||||
callUrl: string;
|
||||
}
|
||||
|
||||
export function addQuota(
|
||||
ctx: Context,
|
||||
unit: Unit = Unit.AuthenticatedRequests,
|
||||
limit: boolean,
|
||||
amount: number,
|
||||
notifications?: Array<notification>,
|
||||
from: Date = (() => {
|
||||
const date = new Date();
|
||||
date.setMonth(0, 1);
|
||||
date.setMinutes(0, 0, 0);
|
||||
// default to start of current year
|
||||
return date;
|
||||
})(),
|
||||
intervalSeconds: string = `${315_576_000_000}s`, // proto max duration is 1000 years
|
||||
failOnStatusCode = true,
|
||||
): Cypress.Chainable<Cypress.Response<any>> {
|
||||
return cy.request({
|
||||
method: 'POST',
|
||||
url: `${ctx.system.baseURL}/instances/${ctx.instanceId}/quotas`,
|
||||
auth: {
|
||||
bearer: ctx.system.token,
|
||||
},
|
||||
body: {
|
||||
unit: unit,
|
||||
amount: amount,
|
||||
resetInterval: intervalSeconds,
|
||||
limit: limit,
|
||||
from: from,
|
||||
notifications: notifications,
|
||||
},
|
||||
failOnStatusCode: failOnStatusCode,
|
||||
});
|
||||
}
|
||||
|
||||
export function ensureQuotaIsAdded(
|
||||
ctx: Context,
|
||||
unit: Unit,
|
||||
limit: boolean,
|
||||
amount?: number,
|
||||
notifications?: Array<notification>,
|
||||
from?: Date,
|
||||
intervalSeconds?: string,
|
||||
): Cypress.Chainable<null> {
|
||||
return addQuota(ctx, unit, limit, amount, notifications, from, intervalSeconds, false).then((res) => {
|
||||
if (!res.isOkStatusCode) {
|
||||
expect(res.status).to.equal(409);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
export function removeQuota(ctx: Context, unit: Unit, failOnStatusCode = true): Cypress.Chainable<Cypress.Response<any>> {
|
||||
return cy.request({
|
||||
method: 'DELETE',
|
||||
url: `${ctx.system.baseURL}/instances/${ctx.instanceId}/quotas/${unit}`,
|
||||
auth: {
|
||||
bearer: ctx.system.token,
|
||||
},
|
||||
failOnStatusCode: failOnStatusCode,
|
||||
});
|
||||
}
|
||||
|
||||
export function ensureQuotaIsRemoved(ctx: Context, unit?: Unit): Cypress.Chainable<null> {
|
||||
return removeQuota(ctx, unit, false).then((res) => {
|
||||
if (!res.isOkStatusCode) {
|
||||
expect(res.status).to.equal(404);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
@@ -1,18 +1,18 @@
|
||||
import { requestHeaders } from './apiauth';
|
||||
import { API, Entity, SearchResult } from './types';
|
||||
import { API, Entity, SearchResult, Token } from './types';
|
||||
|
||||
export function searchSomething(
|
||||
api: API,
|
||||
token: Token,
|
||||
searchPath: string,
|
||||
method: string,
|
||||
mapResult: (body: any) => SearchResult,
|
||||
orgId?: number,
|
||||
orgId?: string,
|
||||
): Cypress.Chainable<SearchResult> {
|
||||
return cy
|
||||
.request({
|
||||
method: method,
|
||||
url: searchPath,
|
||||
headers: requestHeaders(api, orgId),
|
||||
headers: requestHeaders(token, orgId),
|
||||
failOnStatusCode: method == 'POST',
|
||||
})
|
||||
.then((res) => {
|
||||
|
@@ -1,13 +1,25 @@
|
||||
export interface API {
|
||||
export interface Token {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface API extends Token {
|
||||
mgmtBaseURL: string;
|
||||
adminBaseURL: string;
|
||||
authBaseURL: string;
|
||||
assetsBaseURL: string;
|
||||
oidcBaseURL: string;
|
||||
oauthBaseURL: string;
|
||||
samlBaseURL: string;
|
||||
}
|
||||
|
||||
export interface SystemAPI extends Token {
|
||||
baseURL: string;
|
||||
}
|
||||
|
||||
export type SearchResult = {
|
||||
entity: Entity | null;
|
||||
sequence: number;
|
||||
id: number;
|
||||
id: string;
|
||||
};
|
||||
|
||||
// Entity is an object but not a function
|
||||
|
@@ -1,31 +1,23 @@
|
||||
import { requestHeaders } from './apiauth';
|
||||
import { ensureItemDoesntExist, ensureItemExists } from './ensure';
|
||||
import { API } from './types';
|
||||
|
||||
export function ensureHumanUserExists(api: API, username: string): Cypress.Chainable<number> {
|
||||
export function ensureHumanUserExists(api: API, username: string) {
|
||||
return ensureItemExists(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/users/_search`,
|
||||
(user: any) => user.userName === username,
|
||||
`${api.mgmtBaseURL}/users/human`,
|
||||
{
|
||||
...defaultHuman,
|
||||
user_name: username,
|
||||
profile: {
|
||||
first_name: 'e2efirstName',
|
||||
last_name: 'e2elastName',
|
||||
},
|
||||
email: {
|
||||
email: 'e2e@email.ch',
|
||||
},
|
||||
phone: {
|
||||
phone: '+41 123456789',
|
||||
},
|
||||
},
|
||||
undefined,
|
||||
'userId',
|
||||
);
|
||||
}
|
||||
|
||||
export function ensureMachineUserExists(api: API, username: string): Cypress.Chainable<number> {
|
||||
export function ensureMachineUserExists(api: API, username: string) {
|
||||
return ensureItemExists(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/users/_search`,
|
||||
@@ -41,7 +33,7 @@ export function ensureMachineUserExists(api: API, username: string): Cypress.Cha
|
||||
);
|
||||
}
|
||||
|
||||
export function ensureUserDoesntExist(api: API, username: string): Cypress.Chainable<null> {
|
||||
export function ensureUserDoesntExist(api: API, username: string) {
|
||||
return ensureItemDoesntExist(
|
||||
api,
|
||||
`${api.mgmtBaseURL}/users/_search`,
|
||||
@@ -49,3 +41,31 @@ export function ensureUserDoesntExist(api: API, username: string): Cypress.Chain
|
||||
(user) => `${api.mgmtBaseURL}/users/${user.id}`,
|
||||
);
|
||||
}
|
||||
|
||||
export function createHumanUser(api: API, username: string, failOnStatusCode = true) {
|
||||
return cy.request({
|
||||
method: 'POST',
|
||||
url: `${api.mgmtBaseURL}/users/human`,
|
||||
body: {
|
||||
...defaultHuman,
|
||||
user_name: username,
|
||||
},
|
||||
auth: {
|
||||
bearer: api.token,
|
||||
},
|
||||
failOnStatusCode: failOnStatusCode,
|
||||
});
|
||||
}
|
||||
|
||||
const defaultHuman = {
|
||||
profile: {
|
||||
first_name: 'e2efirstName',
|
||||
last_name: 'e2elastName',
|
||||
},
|
||||
email: {
|
||||
email: 'e2e@email.ch',
|
||||
},
|
||||
phone: {
|
||||
phone: '+41 123456789',
|
||||
},
|
||||
};
|
||||
|
@@ -1,29 +1,8 @@
|
||||
import 'cypress-wait-until';
|
||||
//
|
||||
//namespace Cypress {
|
||||
// interface Chainable {
|
||||
// /**
|
||||
// * Custom command that authenticates a user.
|
||||
// *
|
||||
// * @example cy.consolelogin('hodor', 'hodor1234')
|
||||
// */
|
||||
// consolelogin(username: string, password: string): void
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//Cypress.Commands.add('consolelogin', { prevSubject: false }, (username: string, password: string) => {
|
||||
//
|
||||
// window.sessionStorage.removeItem("zitadel:access_token")
|
||||
// cy.visit(Cypress.config('baseUrl')/ui/console).then(() => {
|
||||
// // fill the fields and push button
|
||||
// cy.get('#loginName').type(username, { log: false })
|
||||
// cy.get('#submit-button').click()
|
||||
// cy.get('#password').type(password, { log: false })
|
||||
// cy.get('#submit-button').click()
|
||||
// cy.location('pathname', {timeout: 5 * 1000}).should('eq', '/');
|
||||
// })
|
||||
//})
|
||||
//
|
||||
import { apiAuth, systemAuth } from './api/apiauth';
|
||||
import { API, SystemAPI } from './api/types';
|
||||
import { ensureQuotaIsRemoved, Unit } from './api/quota';
|
||||
import { instanceUnderTest } from './api/instances';
|
||||
|
||||
interface ShouldNotExistOptions {
|
||||
selector: string;
|
||||
@@ -46,7 +25,13 @@ declare global {
|
||||
/**
|
||||
* Custom command that waits until the selector finds zero elements.
|
||||
*/
|
||||
shouldNotExist(options: ShouldNotExistOptions): Cypress.Chainable<null>;
|
||||
shouldNotExist(options?: ShouldNotExistOptions): Cypress.Chainable<null>;
|
||||
|
||||
/**
|
||||
* Custom command that ensures a reliable testing context and returns it
|
||||
*/
|
||||
context(): Cypress.Chainable<Context>;
|
||||
|
||||
/**
|
||||
* Custom command that asserts success is printed after a change.
|
||||
*/
|
||||
@@ -55,6 +40,12 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
export interface Context {
|
||||
api: API;
|
||||
system: SystemAPI;
|
||||
instanceId: number;
|
||||
}
|
||||
|
||||
Cypress.Commands.add('clipboardMatches', { prevSubject: false }, (pattern: RegExp | string) => {
|
||||
/* doesn't work reliably
|
||||
return cy.window()
|
||||
@@ -106,3 +97,35 @@ Cypress.Commands.add('shouldConfirmSuccess', { prevSubject: false }, () => {
|
||||
cy.shouldNotExist({ selector: '.data-e2e-failure' });
|
||||
cy.get('.data-e2e-success');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('context', { prevSubject: false }, () => {
|
||||
return systemAuth().then((system) => {
|
||||
return instanceUnderTest(system).then((instanceId) => {
|
||||
return ensureQuotaIsRemoved(
|
||||
{
|
||||
system: system,
|
||||
api: null,
|
||||
instanceId: instanceId,
|
||||
},
|
||||
Unit.AuthenticatedRequests,
|
||||
).then(() => {
|
||||
return ensureQuotaIsRemoved(
|
||||
{
|
||||
system: system,
|
||||
api: null,
|
||||
instanceId: instanceId,
|
||||
},
|
||||
Unit.ExecutionSeconds,
|
||||
).then(() => {
|
||||
return apiAuth().then((api) => {
|
||||
return {
|
||||
system: system,
|
||||
api: api,
|
||||
instanceId: instanceId,
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -15,6 +15,4 @@
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands';
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
import './types';
|
||||
|
@@ -1,10 +0,0 @@
|
||||
require('cypress-terminal-report/src/installLogsCollector')();
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
module.exports = (on, config) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
};
|
||||
//import './commands'
|
@@ -82,8 +82,10 @@ export function login(
|
||||
|
||||
onAuthenticated ? onAuthenticated() : null;
|
||||
|
||||
cy.visit('/');
|
||||
|
||||
cy.get('[data-e2e=authenticated-welcome]', {
|
||||
timeout: 10_000,
|
||||
timeout: 50_000,
|
||||
});
|
||||
},
|
||||
{
|
||||
|
10
e2e/cypress/support/types.ts
Normal file
10
e2e/cypress/support/types.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
let webhookEventSchema = {
|
||||
unit: 0,
|
||||
id: '',
|
||||
callURL: '',
|
||||
periodStart: new Date(),
|
||||
threshold: 0,
|
||||
usage: 0,
|
||||
};
|
||||
|
||||
export type ZITADELWebhookEvent = typeof webhookEventSchema;
|
Reference in New Issue
Block a user