add named maps Listing auth tests
This commit is contained in:
parent
6a7c9e34a0
commit
9a3eb3e0fd
@ -353,36 +353,72 @@ describe('authorization', function() {
|
|||||||
testClient.drain(done);
|
testClient.drain(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('Listing named maps', function() {
|
||||||
|
|
||||||
it('should fail while listing named maps with a regular apikey token', function (done) {
|
it('should fail while listing named maps with a regular apikey token', function (done) {
|
||||||
const apikeyToken = 'regular1';
|
const apikeyToken = 'regular1';
|
||||||
|
|
||||||
const testClient = new TestClient({}, apikeyToken);
|
const testClient = new TestClient({}, apikeyToken);
|
||||||
|
|
||||||
testClient.getNamedMapList({ response: {status: 403 }}, function (err, res, body) {
|
testClient.getNamedMapList({ response: { status: 403 } }, function (err, res, body) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
|
||||||
assert.equal(res.statusCode, 403);
|
assert.equal(res.statusCode, 403);
|
||||||
|
|
||||||
assert.equal(body.errors.length, 1);
|
assert.equal(body.errors.length, 1);
|
||||||
assert.ok(body.errors[0].match(/Forbidden/), body.errors[0]);
|
assert.ok(body.errors[0].match(/Forbidden/), body.errors[0]);
|
||||||
|
|
||||||
testClient.drain(done);
|
testClient.drain(done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('should list named maps with master apikey token', function (done) {
|
it('should fail while listing named maps with the default apikey token', function (done) {
|
||||||
const apikeyToken = 1234;
|
const apikeyToken = 'default_public';
|
||||||
|
|
||||||
const testClient = new TestClient({}, apikeyToken);
|
const testClient = new TestClient({}, apikeyToken);
|
||||||
|
|
||||||
testClient.getNamedMapList({}, function (err, res, body) {
|
testClient.getNamedMapList({ response: { status: 403 } }, function (err, res, body) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
|
||||||
assert.equal(res.statusCode, 200);
|
assert.equal(res.statusCode, 403);
|
||||||
assert.ok(Array.isArray(body.template_ids));
|
|
||||||
|
|
||||||
testClient.drain(done);
|
assert.equal(body.errors.length, 1);
|
||||||
|
assert.ok(body.errors[0].match(/Forbidden/), body.errors[0]);
|
||||||
|
|
||||||
|
testClient.drain(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail while listing named maps with non-existent apikey token', function (done) {
|
||||||
|
const apikeyToken = 'wadus-wadus';
|
||||||
|
|
||||||
|
const testClient = new TestClient({}, apikeyToken);
|
||||||
|
|
||||||
|
testClient.getNamedMapList({ response: { status: 401 } }, function (err, res, body) {
|
||||||
|
assert.ifError(err);
|
||||||
|
|
||||||
|
assert.equal(res.statusCode, 401);
|
||||||
|
|
||||||
|
assert.equal(body.errors.length, 1);
|
||||||
|
assert.ok(body.errors[0].match(/Unauthorized/), body.errors[0]);
|
||||||
|
|
||||||
|
testClient.drain(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should list named maps with master apikey token', function (done) {
|
||||||
|
const apikeyToken = 1234;
|
||||||
|
|
||||||
|
const testClient = new TestClient({}, apikeyToken);
|
||||||
|
|
||||||
|
testClient.getNamedMapList({}, function (err, res, body) {
|
||||||
|
assert.ifError(err);
|
||||||
|
|
||||||
|
assert.equal(res.statusCode, 200);
|
||||||
|
assert.ok(Array.isArray(body.template_ids));
|
||||||
|
|
||||||
|
testClient.drain(done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user