mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-18 18:16:26 +00:00
Updated cypress entirely
This commit is contained in:
119
test/cypress/e2e/api/Certificates.cy.js
Normal file
119
test/cypress/e2e/api/Certificates.cy.js
Normal file
@ -0,0 +1,119 @@
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
describe('Certificates endpoints', () => {
|
||||
let token;
|
||||
let certID;
|
||||
|
||||
before(() => {
|
||||
cy.getToken().then((tok) => {
|
||||
token = tok;
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to create new certificate', function() {
|
||||
cy.task('backendApiPost', {
|
||||
token: token,
|
||||
path: '/api/certificates',
|
||||
data: {
|
||||
type: 'http',
|
||||
certificate_authority_id: 1,
|
||||
name: 'My First Cert',
|
||||
domain_names: [
|
||||
'jc21.com',
|
||||
'*.google.com'
|
||||
]
|
||||
}
|
||||
}).then((data) => {
|
||||
// Check the swagger schema:
|
||||
cy.validateSwaggerSchema('post', 201, '/certificates', data);
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
expect(data.result.user_id).to.be.greaterThan(0);
|
||||
certID = data.result.id;
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get a certificate', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/certificates/' + certID
|
||||
}).then((data) => {
|
||||
// Check the swagger schema:
|
||||
cy.validateSwaggerSchema('get', 200, '/certificates/{certificateID}', data);
|
||||
expect(data.result).to.have.property('id', certID);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to update a certificate', function() {
|
||||
cy.task('backendApiPut', {
|
||||
token: token,
|
||||
path: '/api/certificates/' + certID,
|
||||
data: {
|
||||
name: 'My Updated Cert'
|
||||
}
|
||||
}).then((data) => {
|
||||
// Check the swagger schema:
|
||||
cy.validateSwaggerSchema('put', 200, '/certificates/{certificateID}', data);
|
||||
expect(data.result).to.have.property('id', certID);
|
||||
expect(data.result).to.have.property('name', 'My Updated Cert');
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all certificates', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/certificates'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/certificates', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('items');
|
||||
expect(data.result.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all certificates with filters A', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/certificates?sort=name&name:starts=my&limit=1'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/certificates', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('items');
|
||||
expect(data.result.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all certificates with filters B', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/certificates?id:in=1,2,3,4,5&limit=1'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/certificates', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('items');
|
||||
expect(data.result.items.length).to.eq(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all certificates with filters C', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/certificates?name:starts=xxxxxxxxxxxxxxx'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/certificates', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('total', 0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to delete a certificate', function() {
|
||||
cy.task('backendApiDelete', {
|
||||
token: token,
|
||||
path: '/api/certificates/' + certID
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('delete', 200, '/certificates/{certificateID}', data);
|
||||
expect(data).to.have.property('result', true);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
95
test/cypress/e2e/api/FullCertProvision.cy.js
Normal file
95
test/cypress/e2e/api/FullCertProvision.cy.js
Normal file
@ -0,0 +1,95 @@
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
describe('Full Certificate Provisions', () => {
|
||||
let token;
|
||||
let caID;
|
||||
let dnsID;
|
||||
|
||||
before(() => {
|
||||
cy.getToken().then((tok) => {
|
||||
token = tok;
|
||||
|
||||
cy.task('backendApiPost', {
|
||||
token: token,
|
||||
path: '/api/certificate-authorities',
|
||||
data: {
|
||||
name: 'Test CA',
|
||||
acmesh_server: 'https://ca.internal/acme/acme/directory',
|
||||
ca_bundle: '/etc/ssl/certs/NginxProxyManager.crt',
|
||||
max_domains: 5,
|
||||
is_wildcard_supported: true
|
||||
}
|
||||
}).then((data) => {
|
||||
// cy.validateSwaggerSchema('post', 201, '/certificate-authorities', data);
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
caID = data.result.id;
|
||||
});
|
||||
|
||||
cy.task('backendApiPost', {
|
||||
token: token,
|
||||
path: '/api/dns-providers',
|
||||
data: {
|
||||
acmesh_name: 'dns_pdns',
|
||||
name: 'PowerDNS - example.com',
|
||||
dns_sleep: 5,
|
||||
meta: {
|
||||
PDNS_Url: 'http://ns1.pdns:8081',
|
||||
PDNS_ServerId: 'localhost',
|
||||
PDNS_Token: 'npm',
|
||||
PDNS_Ttl: 5
|
||||
}
|
||||
}
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('post', 201, '/dns-providers', data);
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
dnsID = data.result.id;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to create new http certificate', function() {
|
||||
cy.task('backendApiPost', {
|
||||
token: token,
|
||||
path: '/api/certificates',
|
||||
data: {
|
||||
type: 'http',
|
||||
certificate_authority_id: caID,
|
||||
name: 'website1.example.com',
|
||||
domain_names: [
|
||||
'website1.example.com'
|
||||
]
|
||||
}
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('post', 201, '/certificates', data);
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
expect(data.result.user_id).to.be.greaterThan(0);
|
||||
cy.waitForCertificateStatus(token, data.result.id, 'provided');
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to create new dns certificate', function() {
|
||||
cy.task('backendApiPost', {
|
||||
token: token,
|
||||
path: '/api/certificates',
|
||||
data: {
|
||||
type: 'dns',
|
||||
certificate_authority_id: caID,
|
||||
dns_provider_id: dnsID,
|
||||
name: 'dns: website2.example.com',
|
||||
domain_names: [
|
||||
'website2.example.com'
|
||||
]
|
||||
}
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('post', 201, '/certificates', data);
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
expect(data.result.user_id).to.be.greaterThan(0);
|
||||
cy.waitForCertificateStatus(token, data.result.id, 'provided');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
12
test/cypress/e2e/api/Health.cy.js
Normal file
12
test/cypress/e2e/api/Health.cy.js
Normal file
@ -0,0 +1,12 @@
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
describe('Basic API checks', () => {
|
||||
it('Should return a valid health payload', function() {
|
||||
cy.task('backendApiGet', {
|
||||
path: '/api/',
|
||||
}).then((data) => {
|
||||
expect(data.result.healthy, 'healthy should equal true').to.equal(true);
|
||||
cy.validateSwaggerSchema('get', 200, '/', data);
|
||||
});
|
||||
});
|
||||
});
|
114
test/cypress/e2e/api/Settings.cy.js
Normal file
114
test/cypress/e2e/api/Settings.cy.js
Normal file
@ -0,0 +1,114 @@
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
// Settings are stored lowercase in the backend
|
||||
|
||||
describe('Settings endpoints', () => {
|
||||
let token;
|
||||
let settingName;
|
||||
|
||||
before(() => {
|
||||
cy.getToken().then((tok) => {
|
||||
token = tok;
|
||||
});
|
||||
cy.randomString(12).then((str) => {
|
||||
settingName = 'cypressSetting_' + str;
|
||||
settingName = settingName.trim();
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to create new setting', function() {
|
||||
cy.task('backendApiPost', {
|
||||
token: token,
|
||||
path: '/api/settings',
|
||||
data: {
|
||||
name: settingName,
|
||||
value: {
|
||||
type: 'custom',
|
||||
html: '<p>not found</p>'
|
||||
}
|
||||
}
|
||||
}).then((data) => {
|
||||
// Check the swagger schema:
|
||||
cy.validateSwaggerSchema('post', 201, '/settings', data);
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get a setting', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/settings/' + settingName
|
||||
}).then((data) => {
|
||||
// Check the swagger schema:
|
||||
cy.validateSwaggerSchema('get', 200, '/settings/{name}', data);
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result).to.have.property('name', settingName.toLowerCase());
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to update a setting', function() {
|
||||
cy.task('backendApiPut', {
|
||||
token: token,
|
||||
path: '/api/settings/' + settingName,
|
||||
data: {
|
||||
value: true
|
||||
}
|
||||
}).then((data) => {
|
||||
// Check the swagger schema:
|
||||
cy.validateSwaggerSchema('put', 200, '/settings/{name}', data);
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result).to.have.property('name', settingName.toLowerCase());
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all settings', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/settings'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/settings', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('items');
|
||||
expect(data.result.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all settings with filters A', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/settings?sort=name&name:starts=e&limit=1'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/settings', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('items');
|
||||
expect(data.result.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all settings with filters B', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/settings?id:in=1,2,3,4,5&limit=1'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/settings', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('items');
|
||||
expect(data.result.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all settings with filters C', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/settings?name:starts=xxxxxxxxxxxxxxx'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/settings', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('total', 0);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
25
test/cypress/e2e/api/SetupPhase.cy.js
Normal file
25
test/cypress/e2e/api/SetupPhase.cy.js
Normal file
@ -0,0 +1,25 @@
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
describe('Setup Phase', () => {
|
||||
|
||||
before(() => {
|
||||
cy.resetUsers();
|
||||
});
|
||||
|
||||
it('Should NOT be able to get a token', function() {
|
||||
cy.task('backendApiPost', {
|
||||
path: '/api/tokens',
|
||||
data: {
|
||||
type: 'password',
|
||||
identity: 'cypress@example.com',
|
||||
secret: 'changeme'
|
||||
},
|
||||
returnOnError: true
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('post', 403, '/tokens', data);
|
||||
expect(data.error).to.have.property('code', 403);
|
||||
expect(data.error).to.have.property('message', 'Not available during setup phase');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
9
test/cypress/e2e/api/SwaggerSchema.cy.js
Normal file
9
test/cypress/e2e/api/SwaggerSchema.cy.js
Normal file
@ -0,0 +1,9 @@
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
describe('Swagger Schema Checks', () => {
|
||||
it('Should be valid with swagger-validator', function() {
|
||||
cy.task('validateSwaggerFile', {
|
||||
file: Cypress.env('swaggerBase')
|
||||
}).should('equal', null);
|
||||
});
|
||||
});
|
67
test/cypress/e2e/api/Upstreams.cy.js
Normal file
67
test/cypress/e2e/api/Upstreams.cy.js
Normal file
@ -0,0 +1,67 @@
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
describe('Upstream endpoints', () => {
|
||||
let token;
|
||||
let upstreamId;
|
||||
|
||||
before(() => {
|
||||
cy.getToken().then((tok) => {
|
||||
token = tok;
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to create new Upstream', function() {
|
||||
cy.task('backendApiPost', {
|
||||
token: token,
|
||||
path: '/api/upstreams',
|
||||
data: {
|
||||
nginx_template_id: 5,
|
||||
name: 'CypressGeneratedUpstreamA',
|
||||
// These servers must be reachable by the Cypress CI stack!
|
||||
servers: [
|
||||
{
|
||||
|
||||
server: 'fullstack:80',
|
||||
weight: 100
|
||||
},
|
||||
{
|
||||
server: 'fullstack:443',
|
||||
weight: 50
|
||||
}
|
||||
]
|
||||
}
|
||||
}).then((data) => {
|
||||
// Check the swagger schema:
|
||||
cy.validateSwaggerSchema('post', 201, '/upstreams', data);
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
upstreamId = data.result.id;
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get a Upstream', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/upstreams/' + upstreamId
|
||||
}).then((data) => {
|
||||
// Check the swagger schema:
|
||||
cy.validateSwaggerSchema('get', 200, '/upstreams/{upstreamID}', data);
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result).to.have.property('name', 'CypressGeneratedUpstreamA');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all Upstreams', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/upstreams'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/upstreams', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('items');
|
||||
expect(data.result.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
190
test/cypress/e2e/api/Users.cy.js
Normal file
190
test/cypress/e2e/api/Users.cy.js
Normal file
@ -0,0 +1,190 @@
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
describe('Users endpoints', () => {
|
||||
let token;
|
||||
let uniqueEmail;
|
||||
let myUserID = 0;
|
||||
|
||||
before(() => {
|
||||
cy.getToken().then((tok) => {
|
||||
token = tok;
|
||||
});
|
||||
cy.randomString(10).then((str) => {
|
||||
uniqueEmail = 'jc_' + str + '@example.com';
|
||||
uniqueEmail = uniqueEmail.trim();
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get yourself', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/users/me'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/users/{userID}', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
myUserID = data.result.id;
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all users', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/users'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/users', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('items');
|
||||
expect(data.result.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all users with filters A', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/users?sort=id.desc&name:starts=c&name:ends=e'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/users', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('items');
|
||||
expect(data.result.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all users with filters B', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/users?sort=id&id:in=1,2,3,4,5'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/users', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('items');
|
||||
expect(data.result.items.length).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to get all users with filters C', function() {
|
||||
cy.task('backendApiGet', {
|
||||
token: token,
|
||||
path: '/api/users?sort=id&name:ends=xxxxxxxxxxxxx'
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('get', 200, '/users', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('total', 0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to create someone else', function() {
|
||||
cy.task('backendApiPost', {
|
||||
token: token,
|
||||
path: '/api/users',
|
||||
data: {
|
||||
name: 'Example user 1',
|
||||
nickname: 'User1',
|
||||
email: uniqueEmail,
|
||||
is_disabled: false,
|
||||
auth: {
|
||||
type: 'password',
|
||||
secret: 'changeme'
|
||||
},
|
||||
capabilities: [
|
||||
'hosts.manage'
|
||||
]
|
||||
}
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('post', 201, '/users', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should not be able to create duplicate email', function() {
|
||||
cy.task('backendApiPost', {
|
||||
token: token,
|
||||
path: '/api/users',
|
||||
returnOnError: true,
|
||||
data: {
|
||||
name: 'Example user 2',
|
||||
nickname: 'User2',
|
||||
email: uniqueEmail,
|
||||
is_disabled: false,
|
||||
auth: {
|
||||
type: 'password',
|
||||
secret: 'changeme'
|
||||
},
|
||||
capabilities: [
|
||||
'hosts.manage'
|
||||
]
|
||||
}
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('post', 400, '/users', data);
|
||||
expect(data).to.have.property('result', null);
|
||||
expect(data).to.have.property('error');
|
||||
expect(data.error).to.have.property('code', 400);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should be able to update yourself', function() {
|
||||
cy.task('backendApiPut', {
|
||||
token: token,
|
||||
path: '/api/users/me',
|
||||
data: {
|
||||
name: 'changed name'
|
||||
}
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('put', 200, '/users/{userID}', data);
|
||||
expect(data).to.have.property('result');
|
||||
expect(data.result).to.have.property('id');
|
||||
expect(data.result.id).to.be.greaterThan(0);
|
||||
expect(data.result.name).to.be.equal('changed name');
|
||||
});
|
||||
});
|
||||
|
||||
it('Should not be able to update email to another user', function() {
|
||||
cy.task('backendApiPut', {
|
||||
token: token,
|
||||
path: '/api/users/me',
|
||||
returnOnError: true,
|
||||
data: {
|
||||
email: uniqueEmail
|
||||
}
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('put', 400, '/users/{userID}', data);
|
||||
expect(data).to.have.property('result', null);
|
||||
expect(data).to.have.property('error');
|
||||
expect(data.error).to.have.property('code', 400);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should not be able to disable yourself', function() {
|
||||
cy.task('backendApiPut', {
|
||||
token: token,
|
||||
path: '/api/users/me',
|
||||
returnOnError: true,
|
||||
data: {
|
||||
is_disabled: true
|
||||
}
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('put', 400, '/users/{userID}', data);
|
||||
expect(data).to.have.property('result', null);
|
||||
expect(data).to.have.property('error');
|
||||
expect(data.error).to.have.property('code', 400);
|
||||
});
|
||||
});
|
||||
|
||||
it('Should not be able to delete yourself', function() {
|
||||
cy.task('backendApiDelete', {
|
||||
token: token,
|
||||
path: '/api/users/' + myUserID,
|
||||
returnOnError: true
|
||||
}).then((data) => {
|
||||
cy.validateSwaggerSchema('delete', 400, '/users/{userID}', data);
|
||||
expect(data).to.have.property('result', null);
|
||||
expect(data).to.have.property('error');
|
||||
expect(data.error).to.have.property('code', 400);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
44
test/cypress/e2e/ui/SetupLogin.cy.js
Normal file
44
test/cypress/e2e/ui/SetupLogin.cy.js
Normal file
@ -0,0 +1,44 @@
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
describe('UI Setup and Login', () => {
|
||||
|
||||
// Clear the users before runing this test
|
||||
before(() => {
|
||||
cy.resetUsers();
|
||||
});
|
||||
|
||||
it('Should be able to setup a new user', function() {
|
||||
cy.visit('/');
|
||||
cy.get('input[name="name"]').type('Cypress McGee');
|
||||
cy.get('input[name="nickname"]').type('Cypress');
|
||||
cy.get('input[name="email"]').type('cypress@example.com');
|
||||
cy.get('input[name="password"]').type('changeme');
|
||||
cy.get('form button:last').click();
|
||||
|
||||
// To fix after chakra change:
|
||||
// cy.get('.navbar-nav .avatar').should('be.visible');
|
||||
|
||||
// logout:
|
||||
cy.clearLocalStorage();
|
||||
});
|
||||
|
||||
it('Should be able to login and change password', function() {
|
||||
cy.visit('/');
|
||||
cy.get('input[name="email"]').type('cypress@example.com');
|
||||
cy.get('input[name="password"]').type('changeme');
|
||||
cy.get('form button:last').click();
|
||||
|
||||
// change password
|
||||
cy.get('button[data-testid="profile-menu"]').should('be.visible').click();
|
||||
cy.get('button[data-testid="profile-menu-change-password"]').should('be.visible').click();
|
||||
cy.get('input[name="current"]').type('changeme');
|
||||
cy.get('input[name="password"]').type('ihavebeenchanged');
|
||||
cy.get('input[name="password2"]').type('ihavebeenchanged');
|
||||
cy.get('form button[data-testid="save"]').click();
|
||||
cy.get('form[data-testid="change-password"]').should('not.exist');
|
||||
|
||||
// logout:
|
||||
cy.clearLocalStorage();
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user