67 lines
2.3 KiB
JavaScript
67 lines
2.3 KiB
JavaScript
|
|
/* jslint node:true */
|
||
|
|
/* global it:false */
|
||
|
|
/* global describe:false */
|
||
|
|
/* global before:false */
|
||
|
|
/* global after:false */
|
||
|
|
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
const dockerRegistries = require('../dockerregistries.js'),
|
||
|
|
BoxError = require('../boxerror.js'),
|
||
|
|
common = require('./common.js'),
|
||
|
|
expect = require('expect.js'),
|
||
|
|
safe = require('safetydance');
|
||
|
|
|
||
|
|
describe('Docker Registries', function () {
|
||
|
|
const { setup, cleanup, auditSource } = common;
|
||
|
|
|
||
|
|
before(setup);
|
||
|
|
after(cleanup);
|
||
|
|
|
||
|
|
let id;
|
||
|
|
|
||
|
|
it('cannot get random', async function () {
|
||
|
|
const registry = await dockerRegistries.get('srandom');
|
||
|
|
expect(registry).to.be(null);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('can add', async function () {
|
||
|
|
id = await dockerRegistries.add({ provider: 'devops', serverAddress: 'registry.devops.test', password: 'hushhush' }, auditSource);
|
||
|
|
expect(id).to.be.a('string');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('can get', async function () {
|
||
|
|
const registry = await dockerRegistries.get(id);
|
||
|
|
expect(registry.provider).to.be('devops');
|
||
|
|
expect(registry.serverAddress).to.be('registry.devops.test');
|
||
|
|
expect(registry.password).to.be('hushhush');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('can list', async function () {
|
||
|
|
const registries = await dockerRegistries.list();
|
||
|
|
expect(registries.length).to.be(1);
|
||
|
|
expect(registries[0].provider).to.be('devops');
|
||
|
|
expect(registries[0].serverAddress).to.be('registry.devops.test');
|
||
|
|
expect(registries[0].password).to.be('hushhush');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('can update', async function () {
|
||
|
|
await dockerRegistries.update(await dockerRegistries.get(id), { provider: 'cicd', serverAddress: 'registry.cicd' }, auditSource);
|
||
|
|
const registry = await dockerRegistries.get(id);
|
||
|
|
expect(registry.provider).to.be('cicd');
|
||
|
|
expect(registry.serverAddress).to.be('registry.cicd');
|
||
|
|
expect(registry.password).to.be('hushhush'); // injected from the older one
|
||
|
|
});
|
||
|
|
|
||
|
|
it('can del', async function () {
|
||
|
|
await dockerRegistries.del(await dockerRegistries.get(id), auditSource);
|
||
|
|
const registries = await dockerRegistries.list();
|
||
|
|
expect(registries.length).to.be(0);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('cannot del random', async function () {
|
||
|
|
const [error] = await safe(dockerRegistries.del({ id: 'fake' }, auditSource));
|
||
|
|
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||
|
|
});
|
||
|
|
});
|