navy
Version:
Quick and powerful development environments using Docker and Docker Compose
26 lines (24 loc) • 945 B
JavaScript
;
var _chai = require("chai");
var _helpers = require("../helpers");
/* eslint-env mocha */
describe('registry helpers', function () {
describe('basicAuthentication', function () {
it('should return null for empty credentials', function () {
(0, _chai.expect)((0, _helpers.basicAuthentication)({})).to.equal(null);
});
it('should base64-encode user:password into a Basic header', function () {
const result = (0, _helpers.basicAuthentication)({
username: 'alice',
password: 's3cret'
});
(0, _chai.expect)(result).to.equal('Basic ' + Buffer.from('alice:s3cret').toString('base64'));
});
it('should still return a Basic header for non-empty objects with empty values', function () {
(0, _chai.expect)((0, _helpers.basicAuthentication)({
username: '',
password: ''
})).to.equal('Basic ' + Buffer.from(':').toString('base64'));
});
});
});