From d96a3987c0d6c679059af47bec33f8d94f7e4d78 Mon Sep 17 00:00:00 2001 From: Nephiel Date: Wed, 16 Oct 2024 19:04:50 +0000 Subject: [PATCH 1/4] Fix forward_scheme validation in Redirection Host Should solve error `data/forward_scheme must be equal to one of the allowed values` when configuring a Redirection Host with scheme set to `auto`. #4074 --- backend/schema/components/redirection-host-object.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/schema/components/redirection-host-object.json b/backend/schema/components/redirection-host-object.json index cc4dbdd2f..e7a495fd3 100644 --- a/backend/schema/components/redirection-host-object.json +++ b/backend/schema/components/redirection-host-object.json @@ -28,7 +28,7 @@ }, "forward_scheme": { "type": "string", - "enum": ["http", "https"] + "enum": ["auto", "http", "https"] }, "forward_domain_name": { "description": "Domain Name", From fa2c814fcb76b6a11b979dc23a817853a459644d Mon Sep 17 00:00:00 2001 From: Nephiel Date: Wed, 16 Oct 2024 19:09:14 +0000 Subject: [PATCH 2/4] Fix schema validation in Default Site Should solve error `data/value must match exactly one schema in oneOf` when setting the Default Site to 404 or 444. #4074 --- backend/schema/components/setting-object.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/schema/components/setting-object.json b/backend/schema/components/setting-object.json index e08777264..65ec2a08e 100644 --- a/backend/schema/components/setting-object.json +++ b/backend/schema/components/setting-object.json @@ -25,7 +25,7 @@ "value": { "description": "Value in almost any form", "example": "congratulations", - "oneOf": [ + "anyOf": [ { "type": "string", "minLength": 1 From edbed1af90ab86658a9fc4a17ef571797484edcc Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Thu, 17 Oct 2024 08:48:47 +1000 Subject: [PATCH 3/4] Adds tests for settings endpoints and reenables dns cert test and fixes problems with schema --- backend/internal/nginx.js | 4 +- .../schema/components/proxy-host-object.json | 10 +- backend/schema/components/setting-object.json | 5 +- .../paths/nginx/dead-hosts/hostID/put.json | 4 +- .../schema/paths/nginx/dead-hosts/post.json | 4 +- .../paths/nginx/proxy-hosts/hostID/put.json | 4 +- .../schema/paths/nginx/proxy-hosts/post.json | 4 +- .../nginx/redirection-hosts/hostID/put.json | 4 +- .../paths/nginx/redirection-hosts/post.json | 4 +- .../paths/nginx/streams/streamID/put.json | 4 +- .../schema/paths/settings/settingID/put.json | 18 ++- test/cypress/e2e/api/FullCertProvision.cy.js | 7 +- .../e2e/api/{Hosts.cy.js => ProxyHosts.cy.js} | 2 +- test/cypress/e2e/api/Settings.cy.js | 124 ++++++++++++++++++ test/cypress/plugins/backendApi/client.js | 2 +- 15 files changed, 160 insertions(+), 40 deletions(-) rename test/cypress/e2e/api/{Hosts.cy.js => ProxyHosts.cy.js} (96%) create mode 100644 test/cypress/e2e/api/Settings.cy.js diff --git a/backend/internal/nginx.js b/backend/internal/nginx.js index 77933e733..5f802c004 100644 --- a/backend/internal/nginx.js +++ b/backend/internal/nginx.js @@ -181,7 +181,9 @@ const internalNginx = { * @param {Object} host * @returns {Promise} */ - generateConfig: (host_type, host) => { + generateConfig: (host_type, host_row) => { + // Prevent modifying the original object: + let host = JSON.parse(JSON.stringify(host_row)); const nice_host_type = internalNginx.getFileFriendlyHostType(host_type); if (config.debug()) { diff --git a/backend/schema/components/proxy-host-object.json b/backend/schema/components/proxy-host-object.json index a64a58c8f..5098802b1 100644 --- a/backend/schema/components/proxy-host-object.json +++ b/backend/schema/components/proxy-host-object.json @@ -23,9 +23,7 @@ "locations", "hsts_enabled", "hsts_subdomains", - "certificate", - "use_default_location", - "ipv6" + "certificate" ], "additionalProperties": false, "properties": { @@ -151,12 +149,6 @@ "$ref": "./access-list-object.json" } ] - }, - "use_default_location": { - "type": "boolean" - }, - "ipv6": { - "type": "boolean" } } } diff --git a/backend/schema/components/setting-object.json b/backend/schema/components/setting-object.json index 65ec2a08e..b9c6a1039 100644 --- a/backend/schema/components/setting-object.json +++ b/backend/schema/components/setting-object.json @@ -46,7 +46,10 @@ }, "meta": { "description": "Extra metadata", - "example": {}, + "example": { + "redirect": "http://example.com", + "html": "

404

" + }, "type": "object" } } diff --git a/backend/schema/paths/nginx/dead-hosts/hostID/put.json b/backend/schema/paths/nginx/dead-hosts/hostID/put.json index 6a0a57e3a..f9505ed48 100644 --- a/backend/schema/paths/nginx/dead-hosts/hostID/put.json +++ b/backend/schema/paths/nginx/dead-hosts/hostID/put.json @@ -94,9 +94,7 @@ "avatar": "", "roles": ["admin"] }, - "certificate": null, - "use_default_location": true, - "ipv6": true + "certificate": null } } }, diff --git a/backend/schema/paths/nginx/dead-hosts/post.json b/backend/schema/paths/nginx/dead-hosts/post.json index 593135065..c8bbb6932 100644 --- a/backend/schema/paths/nginx/dead-hosts/post.json +++ b/backend/schema/paths/nginx/dead-hosts/post.json @@ -79,9 +79,7 @@ "nickname": "Admin", "avatar": "", "roles": ["admin"] - }, - "use_default_location": true, - "ipv6": true + } } } }, diff --git a/backend/schema/paths/nginx/proxy-hosts/hostID/put.json b/backend/schema/paths/nginx/proxy-hosts/hostID/put.json index af73905dc..5cab6e752 100644 --- a/backend/schema/paths/nginx/proxy-hosts/hostID/put.json +++ b/backend/schema/paths/nginx/proxy-hosts/hostID/put.json @@ -129,9 +129,7 @@ "roles": ["admin"] }, "certificate": null, - "access_list": null, - "use_default_location": true, - "ipv6": true + "access_list": null } } }, diff --git a/backend/schema/paths/nginx/proxy-hosts/post.json b/backend/schema/paths/nginx/proxy-hosts/post.json index 13f641610..85455fb6b 100644 --- a/backend/schema/paths/nginx/proxy-hosts/post.json +++ b/backend/schema/paths/nginx/proxy-hosts/post.json @@ -114,9 +114,7 @@ "avatar": "//www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?default=mm", "roles": ["admin"] }, - "access_list": null, - "use_default_location": true, - "ipv6": true + "access_list": null } } }, diff --git a/backend/schema/paths/nginx/redirection-hosts/hostID/put.json b/backend/schema/paths/nginx/redirection-hosts/hostID/put.json index 870f16fcd..fd97cbfa8 100644 --- a/backend/schema/paths/nginx/redirection-hosts/hostID/put.json +++ b/backend/schema/paths/nginx/redirection-hosts/hostID/put.json @@ -114,9 +114,7 @@ "avatar": "", "roles": ["admin"] }, - "certificate": null, - "use_default_location": true, - "ipv6": true + "certificate": null } } }, diff --git a/backend/schema/paths/nginx/redirection-hosts/post.json b/backend/schema/paths/nginx/redirection-hosts/post.json index 3a9a05fec..5bfde2c38 100644 --- a/backend/schema/paths/nginx/redirection-hosts/post.json +++ b/backend/schema/paths/nginx/redirection-hosts/post.json @@ -99,9 +99,7 @@ "nickname": "Admin", "avatar": "", "roles": ["admin"] - }, - "use_default_location": true, - "ipv6": true + } } } }, diff --git a/backend/schema/paths/nginx/streams/streamID/put.json b/backend/schema/paths/nginx/streams/streamID/put.json index f3ef54d47..fbfdc901b 100644 --- a/backend/schema/paths/nginx/streams/streamID/put.json +++ b/backend/schema/paths/nginx/streams/streamID/put.json @@ -129,9 +129,7 @@ "roles": ["admin"] }, "certificate": null, - "access_list": null, - "use_default_location": true, - "ipv6": true + "access_list": null } } }, diff --git a/backend/schema/paths/settings/settingID/put.json b/backend/schema/paths/settings/settingID/put.json index 5888ec056..4ca624293 100644 --- a/backend/schema/paths/settings/settingID/put.json +++ b/backend/schema/paths/settings/settingID/put.json @@ -13,7 +13,8 @@ "name": "settingID", "schema": { "type": "string", - "minLength": 1 + "minLength": 1, + "enum": ["default-site"] }, "required": true, "description": "Setting ID", @@ -31,10 +32,21 @@ "minProperties": 1, "properties": { "value": { - "$ref": "../../../components/setting-object.json#/properties/value" + "type": "string", + "minLength": 1, + "enum": ["congratulations", "404", "444", "redirect", "html"] }, "meta": { - "$ref": "../../../components/setting-object.json#/properties/meta" + "type": "object", + "additionalProperties": false, + "properties": { + "redirect": { + "type": "string" + }, + "html": { + "type": "string" + } + } } } } diff --git a/test/cypress/e2e/api/FullCertProvision.cy.js b/test/cypress/e2e/api/FullCertProvision.cy.js index 93cacce9e..5ca5692cd 100644 --- a/test/cypress/e2e/api/FullCertProvision.cy.js +++ b/test/cypress/e2e/api/FullCertProvision.cy.js @@ -9,7 +9,7 @@ describe('Full Certificate Provisions', () => { }); }); - it.only('Should be able to create new http certificate', function() { + it('Should be able to create new http certificate', function() { cy.task('backendApiPost', { token: token, path: '/api/nginx/certificates', @@ -35,7 +35,7 @@ describe('Full Certificate Provisions', () => { it('Should be able to create new DNS certificate with Powerdns', function() { cy.task('backendApiPost', { token: token, - path: '/api/certificates', + path: '/api/nginx/certificates', data: { domain_names: [ 'website2.example.com' @@ -45,7 +45,8 @@ describe('Full Certificate Provisions', () => { dns_challenge: true, dns_provider: 'powerdns', dns_provider_credentials: 'dns_powerdns_api_url = http://ns1.pdns:8081\r\ndns_powerdns_api_key = npm', - letsencrypt_agree: true + letsencrypt_agree: true, + propagation_seconds: 5, }, provider: 'letsencrypt' } diff --git a/test/cypress/e2e/api/Hosts.cy.js b/test/cypress/e2e/api/ProxyHosts.cy.js similarity index 96% rename from test/cypress/e2e/api/Hosts.cy.js rename to test/cypress/e2e/api/ProxyHosts.cy.js index 75d732c7c..5bc645800 100644 --- a/test/cypress/e2e/api/Hosts.cy.js +++ b/test/cypress/e2e/api/ProxyHosts.cy.js @@ -1,6 +1,6 @@ /// -describe('Hosts endpoints', () => { +describe('Proxy Hosts endpoints', () => { let token; before(() => { diff --git a/test/cypress/e2e/api/Settings.cy.js b/test/cypress/e2e/api/Settings.cy.js new file mode 100644 index 000000000..6942760c7 --- /dev/null +++ b/test/cypress/e2e/api/Settings.cy.js @@ -0,0 +1,124 @@ +/// + +describe('Settings endpoints', () => { + let token; + + before(() => { + cy.getToken().then((tok) => { + token = tok; + }); + }); + + it('Get all settings', function() { + cy.task('backendApiGet', { + token: token, + path: '/api/settings', + }).then((data) => { + cy.validateSwaggerSchema('get', 200, '/settings', data); + expect(data.length).to.be.greaterThan(0); + }); + }); + + it('Get default-site setting', function() { + cy.task('backendApiGet', { + token: token, + path: '/api/settings/default-site', + }).then((data) => { + cy.validateSwaggerSchema('get', 200, '/settings/{settingID}', data); + expect(data).to.have.property('id'); + expect(data.id).to.be.equal('default-site'); + }); + }); + + it('Default Site congratulations', function() { + cy.task('backendApiPut', { + token: token, + path: '/api/settings/default-site', + data: { + value: 'congratulations', + }, + }).then((data) => { + cy.validateSwaggerSchema('put', 200, '/settings/{settingID}', data); + expect(data).to.have.property('id'); + expect(data.id).to.be.equal('default-site'); + expect(data).to.have.property('value'); + expect(data.value).to.be.equal('congratulations'); + }); + }); + + it('Default Site 404', function() { + cy.task('backendApiPut', { + token: token, + path: '/api/settings/default-site', + data: { + value: '404', + }, + }).then((data) => { + cy.validateSwaggerSchema('put', 200, '/settings/{settingID}', data); + expect(data).to.have.property('id'); + expect(data.id).to.be.equal('default-site'); + expect(data).to.have.property('value'); + expect(data.value).to.be.equal('404'); + }); + }); + + it('Default Site 444', function() { + cy.task('backendApiPut', { + token: token, + path: '/api/settings/default-site', + data: { + value: '444', + }, + }).then((data) => { + cy.validateSwaggerSchema('put', 200, '/settings/{settingID}', data); + expect(data).to.have.property('id'); + expect(data.id).to.be.equal('default-site'); + expect(data).to.have.property('value'); + expect(data.value).to.be.equal('444'); + }); + }); + + it('Default Site redirect', function() { + cy.task('backendApiPut', { + token: token, + path: '/api/settings/default-site', + data: { + value: 'redirect', + meta: { + redirect: 'https://www.google.com', + }, + }, + }).then((data) => { + cy.validateSwaggerSchema('put', 200, '/settings/{settingID}', data); + expect(data).to.have.property('id'); + expect(data.id).to.be.equal('default-site'); + expect(data).to.have.property('value'); + expect(data.value).to.be.equal('redirect'); + expect(data).to.have.property('meta'); + expect(data.meta).to.have.property('redirect'); + expect(data.meta.redirect).to.be.equal('https://www.google.com'); + }); + }); + + it('Default Site html', function() { + cy.task('backendApiPut', { + token: token, + path: '/api/settings/default-site', + data: { + value: 'html', + meta: { + html: '

hello world

' + }, + }, + }).then((data) => { + cy.validateSwaggerSchema('put', 200, '/settings/{settingID}', data); + expect(data).to.have.property('id'); + expect(data.id).to.be.equal('default-site'); + expect(data).to.have.property('value'); + expect(data.value).to.be.equal('html'); + expect(data).to.have.property('meta'); + expect(data.meta).to.have.property('html'); + expect(data.meta.html).to.be.equal('

hello world

'); + }); + }); +}); diff --git a/test/cypress/plugins/backendApi/client.js b/test/cypress/plugins/backendApi/client.js index c10653e41..6f5f7661e 100644 --- a/test/cypress/plugins/backendApi/client.js +++ b/test/cypress/plugins/backendApi/client.js @@ -7,7 +7,7 @@ const BackendApi = function(config, token) { this.axios = axios.create({ baseURL: config.baseUrl, - timeout: 60000, + timeout: 90000, }); }; From 2f9e062718d0d66fcff0e240ac47533bb1fcbda4 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Thu, 17 Oct 2024 09:05:25 +1000 Subject: [PATCH 4/4] bump version --- .version | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.version b/.version index d8b698973..3cf561c0b 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -2.12.0 +2.12.1 diff --git a/README.md b/README.md index 2d1b8da5b..9ac6a6c85 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@



- +