registry config: create table and migrate existing setting
This commit is contained in:
@@ -134,7 +134,7 @@ async function setup() {
|
||||
|
||||
await timers.setTimeout(2000);
|
||||
|
||||
// create admin
|
||||
// create owner
|
||||
response = await superagent.post(`${serverUrl}/api/v1/provision/activate`)
|
||||
.query({ setupToken: 'somesetuptoken' })
|
||||
.send({ username: owner.username, password: owner.password, email: owner.email });
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/* jslint node:true */
|
||||
/* global it:false */
|
||||
/* global describe:false */
|
||||
/* global before:false */
|
||||
/* global after:false */
|
||||
|
||||
'use strict';
|
||||
|
||||
const common = require('./common.js'),
|
||||
constants = require('../../constants.js'),
|
||||
expect = require('expect.js'),
|
||||
superagent = require('../../superagent.js');
|
||||
|
||||
describe('Docker Registries', function () {
|
||||
const { setup, cleanup, serverUrl, owner } = common;
|
||||
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
|
||||
it('cannot add registry with invalid token', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/docker/registries`)
|
||||
.query({ access_token: owner.token + 'xx' })
|
||||
.send({ provider: 'devops', serverAddress: 'registry.devops' })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.status).to.equal(401);
|
||||
});
|
||||
|
||||
it('cannot add registry without provider', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/docker/registries`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({})
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.status).to.equal(400);
|
||||
});
|
||||
|
||||
let id;
|
||||
it('can add registry', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/docker/registries`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ provider: 'devops', serverAddress: 'registry.devops', password: 'hushhush' });
|
||||
|
||||
expect(response.status).to.equal(201);
|
||||
expect(response.body.id).to.be.a('string');
|
||||
id = response.body.id;
|
||||
});
|
||||
|
||||
it('can list registries', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/docker/registries`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.registries).to.be.an(Array);
|
||||
expect(response.body.registries.length).to.be(1);
|
||||
expect(response.body.registries[0].provider).to.be('devops');
|
||||
expect(response.body.registries[0].serverAddress).to.be('registry.devops');
|
||||
expect(response.body.registries[0].password).to.be(constants.SECRET_PLACEHOLDER);
|
||||
});
|
||||
|
||||
it('can update registry', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/docker/registries/${id}`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ provider: 'devops2', serverAddress: 'registry.devops2', password: 'hushhush2' });
|
||||
|
||||
expect(response.status).to.equal(204);
|
||||
});
|
||||
|
||||
it('can get registry', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/docker/registries/${id}`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.provider).to.be('devops2');
|
||||
expect(response.body.serverAddress).to.be('registry.devops2');
|
||||
expect(response.body.password).to.be(constants.SECRET_PLACEHOLDER);
|
||||
});
|
||||
|
||||
it('can del registry', async function () {
|
||||
const response = await superagent.del(`${serverUrl}/api/v1/docker/registries/${id}`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.status).to.equal(204);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user