Add field to configure the reverse proxy

part of #596
This commit is contained in:
Girish Ramakrishnan
2019-10-13 18:22:03 -07:00
parent 7383cc4e90
commit 9c12f1fe15
11 changed files with 177 additions and 42 deletions

View File

@@ -1040,18 +1040,9 @@ describe('App API', function () {
});
});
describe('configure robotsTxt', function () {
it('fails with missing robotsTxt', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/robots_txt')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
done();
});
});
describe('configure reverseProxy - robotsTxt', function () {
it('fails with bad robotsTxt', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/robots_txt')
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/reverse_proxy')
.query({ access_token: token })
.send({ robotsTxt: 34 })
.end(function (err, res) {
@@ -1061,9 +1052,9 @@ describe('App API', function () {
});
it('can set robotsTxt', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/robots_txt')
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/reverse_proxy')
.query({ access_token: token })
.send({ robotsTxt: 'any string is good' })
.send({ robotsTxt: 'any string is good', frameAncestors: [], hideHeaders: [] })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
done();
@@ -1071,9 +1062,69 @@ describe('App API', function () {
});
it('can reset robotsTxt', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/robots_txt')
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/reverse_proxy')
.query({ access_token: token })
.send({ robotsTxt: null })
.send({ robotsTxt: null, frameAncestors: [], hideHeaders: [] })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
done();
});
});
it('fails with bad frame-ancestors', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/reverse_proxy')
.query({ access_token: token })
.send({ robotsTxt: null, frameAncestors: [ 34 ], hideHeaders: [] })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
done();
});
});
it('can set frame-ancestors', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/reverse_proxy')
.query({ access_token: token })
.send({ robotsTxt: null, frameAncestors: [ 'www.example.com' ], hideHeaders: [] })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
done();
});
});
it('can reset frame-ancestors', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/reverse_proxy')
.query({ access_token: token })
.send({ robotsTxt: null, frameAncestors: [], hideHeaders: [] })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
done();
});
});
it('fails with bad hideHeaders', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/reverse_proxy')
.query({ access_token: token })
.send({ robotsTxt: null, frameAncestors: [], hideHeaders: 34 })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
done();
});
});
it('can set hideHeaders', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/reverse_proxy')
.query({ access_token: token })
.send({ robotsTxt: null, frameAncestors: [], hideHeaders: [ 'Content-Security-Policy' ] })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
done();
});
});
it('can reset hideHeaders', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/reverse_proxy')
.query({ access_token: token })
.send({ robotsTxt: null, frameAncestors: [], hideHeaders: [] })
.end(function (err, res) {
expect(res.statusCode).to.equal(200);
done();