mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-21 06:31:07 +02:00
* fix default rendering of svg and allow plugins access to mount tune form * add auth-jwt component * add callback route, and allow it to be navigated to on load * add jwt as a supported auth method * use auth-jwt component and implement intial oidc flow * allow wrapping un-authed requests * pass redirect_url and properly redirect with the wrapped token * popup for login * center popup window and move to localStorage events for cross window communication because of IE11 * access window via a getter on the auth-form component * show OIDC provider name on the button * fetch default role on render of the auth-jwt component * simplify auth-form template * style callback page * refetch auth_url when path changes for auth-jwt component * fix glimmer error on alias metadata, and add back popup-metadata component * fix link in metadata page * add logo-edition component and remove use of partial for logo svg * render oidc callback template on the loading page if we're going there * add docs icon and change timeout on the auth form * move OIDC auth specific things to auth-jwt component * start to add branded buttons for OIDC providers * add google button * finish branded buttons * update glyph for error messages * update tests for auth screen not showing tabs, add adapter tests and new auth jwt tests * start auth-jwt tests * simplify auth-jwt * remove negative top margin on AlertInline * only preventDefault if there's an event * fill out tests * sort out some naming * feedback on templates and styles * clear error when starting OIDC auth and call for new auth_url * also allow 'oidc' as the auth method type * handle namespaces with OIDC auth * review feedback * use new getters in popup-metadata
218 lines
8.5 KiB
JavaScript
218 lines
8.5 KiB
JavaScript
import { resolve } from 'rsvp';
|
|
import { module, test } from 'qunit';
|
|
import { setupTest } from 'ember-qunit';
|
|
|
|
module('Unit | Adapter | cluster', function(hooks) {
|
|
setupTest(hooks);
|
|
|
|
test('cluster api urls', function(assert) {
|
|
let url, method, options;
|
|
let adapter = this.owner.factoryFor('adapter:cluster').create({
|
|
ajax: (...args) => {
|
|
[url, method, options] = args;
|
|
return resolve();
|
|
},
|
|
});
|
|
adapter.health();
|
|
assert.equal('/v1/sys/health', url, 'health url OK');
|
|
assert.deepEqual(
|
|
{
|
|
standbycode: 200,
|
|
sealedcode: 200,
|
|
uninitcode: 200,
|
|
drsecondarycode: 200,
|
|
performancestandbycode: 200,
|
|
},
|
|
options.data,
|
|
'health data params OK'
|
|
);
|
|
assert.equal('GET', method, 'health method OK');
|
|
|
|
adapter.sealStatus();
|
|
assert.equal('/v1/sys/seal-status', url, 'health url OK');
|
|
assert.equal('GET', method, 'seal-status method OK');
|
|
|
|
let data = { someData: 1 };
|
|
adapter.unseal(data);
|
|
assert.equal('/v1/sys/unseal', url, 'unseal url OK');
|
|
assert.equal('PUT', method, 'unseal method OK');
|
|
assert.deepEqual({ data, unauthenticated: true }, options, 'unseal options OK');
|
|
|
|
adapter.initCluster(data);
|
|
assert.equal('/v1/sys/init', url, 'init url OK');
|
|
assert.equal('PUT', method, 'init method OK');
|
|
assert.deepEqual({ data, unauthenticated: true }, options, 'init options OK');
|
|
|
|
data = { token: 'token', password: 'password', username: 'username' };
|
|
|
|
adapter.authenticate({ backend: 'token', data });
|
|
assert.equal('/v1/auth/token/lookup-self', url, 'auth:token url OK');
|
|
assert.equal('GET', method, 'auth:token method OK');
|
|
assert.deepEqual(
|
|
{ headers: { 'X-Vault-Token': 'token' }, unauthenticated: true },
|
|
options,
|
|
'auth:token options OK'
|
|
);
|
|
|
|
adapter.authenticate({ backend: 'github', data });
|
|
assert.equal('/v1/auth/github/login', url, 'auth:github url OK');
|
|
assert.equal('POST', method, 'auth:github method OK');
|
|
assert.deepEqual(
|
|
{ data: { password: 'password', token: 'token' }, unauthenticated: true },
|
|
options,
|
|
'auth:github options OK'
|
|
);
|
|
|
|
data = { jwt: 'token', role: 'test' };
|
|
adapter.authenticate({ backend: 'jwt', data });
|
|
assert.equal('/v1/auth/jwt/login', url, 'auth:jwt url OK');
|
|
assert.equal('POST', method, 'auth:jwt method OK');
|
|
assert.deepEqual(
|
|
{ data: { jwt: 'token', role: 'test' }, unauthenticated: true },
|
|
options,
|
|
'auth:jwt options OK'
|
|
);
|
|
|
|
data = { jwt: 'token', role: 'test', path: 'oidc' };
|
|
adapter.authenticate({ backend: 'jwt', data });
|
|
assert.equal('/v1/auth/oidc/login', url, 'auth:jwt custom mount path, url OK');
|
|
|
|
data = { token: 'token', password: 'password', username: 'username', path: 'path' };
|
|
|
|
adapter.authenticate({ backend: 'token', data });
|
|
assert.equal('/v1/auth/token/lookup-self', url, 'auth:token url with path OK');
|
|
|
|
adapter.authenticate({ backend: 'github', data });
|
|
assert.equal('/v1/auth/path/login', url, 'auth:github with path url OK');
|
|
|
|
data = { password: 'password', username: 'username' };
|
|
|
|
adapter.authenticate({ backend: 'userpass', data });
|
|
assert.equal('/v1/auth/userpass/login/username', url, 'auth:userpass url OK');
|
|
assert.equal('POST', method, 'auth:userpass method OK');
|
|
assert.deepEqual(
|
|
{ data: { password: 'password' }, unauthenticated: true },
|
|
options,
|
|
'auth:userpass options OK'
|
|
);
|
|
|
|
adapter.authenticate({ backend: 'LDAP', data });
|
|
assert.equal('/v1/auth/ldap/login/username', url, 'ldap:userpass url OK');
|
|
assert.equal('POST', method, 'ldap:userpass method OK');
|
|
assert.deepEqual(
|
|
{ data: { password: 'password' }, unauthenticated: true },
|
|
options,
|
|
'ldap:userpass options OK'
|
|
);
|
|
|
|
adapter.authenticate({ backend: 'okta', data });
|
|
assert.equal('/v1/auth/okta/login/username', url, 'okta:userpass url OK');
|
|
assert.equal('POST', method, 'ldap:userpass method OK');
|
|
assert.deepEqual(
|
|
{ data: { password: 'password' }, unauthenticated: true },
|
|
options,
|
|
'okta:userpass options OK'
|
|
);
|
|
|
|
// use a custom mount path
|
|
data = { password: 'password', username: 'username', path: 'path' };
|
|
|
|
adapter.authenticate({ backend: 'userpass', data });
|
|
assert.equal('/v1/auth/path/login/username', url, 'auth:userpass with path url OK');
|
|
|
|
adapter.authenticate({ backend: 'LDAP', data });
|
|
assert.equal('/v1/auth/path/login/username', url, 'auth:LDAP with path url OK');
|
|
|
|
adapter.authenticate({ backend: 'Okta', data });
|
|
assert.equal('/v1/auth/path/login/username', url, 'auth:Okta with path url OK');
|
|
});
|
|
|
|
test('cluster replication api urls', function(assert) {
|
|
let url, method, options;
|
|
let adapter = this.owner.factoryFor('adapter:cluster').create({
|
|
ajax: (...args) => {
|
|
[url, method, options] = args;
|
|
return resolve();
|
|
},
|
|
});
|
|
|
|
adapter.replicationStatus();
|
|
assert.equal('/v1/sys/replication/status', url, 'replication:status url OK');
|
|
assert.equal('GET', method, 'replication:status method OK');
|
|
assert.deepEqual({ unauthenticated: true }, options, 'replication:status options OK');
|
|
|
|
adapter.replicationAction('recover', 'dr');
|
|
assert.equal('/v1/sys/replication/recover', url, 'replication: recover url OK');
|
|
assert.equal('POST', method, 'replication:recover method OK');
|
|
|
|
adapter.replicationAction('reindex', 'dr');
|
|
assert.equal('/v1/sys/replication/reindex', url, 'replication: reindex url OK');
|
|
assert.equal('POST', method, 'replication:reindex method OK');
|
|
|
|
adapter.replicationAction('enable', 'dr', 'primary');
|
|
assert.equal('/v1/sys/replication/dr/primary/enable', url, 'replication:dr primary:enable url OK');
|
|
assert.equal('POST', method, 'replication:primary:enable method OK');
|
|
adapter.replicationAction('enable', 'performance', 'primary');
|
|
assert.equal(
|
|
'/v1/sys/replication/performance/primary/enable',
|
|
url,
|
|
'replication:performance primary:enable url OK'
|
|
);
|
|
|
|
adapter.replicationAction('enable', 'dr', 'secondary');
|
|
assert.equal('/v1/sys/replication/dr/secondary/enable', url, 'replication:dr secondary:enable url OK');
|
|
assert.equal('POST', method, 'replication:secondary:enable method OK');
|
|
adapter.replicationAction('enable', 'performance', 'secondary');
|
|
assert.equal(
|
|
'/v1/sys/replication/performance/secondary/enable',
|
|
url,
|
|
'replication:performance secondary:enable url OK'
|
|
);
|
|
|
|
adapter.replicationAction('disable', 'dr', 'primary');
|
|
assert.equal('/v1/sys/replication/dr/primary/disable', url, 'replication:dr primary:disable url OK');
|
|
assert.equal('POST', method, 'replication:primary:disable method OK');
|
|
adapter.replicationAction('disable', 'performance', 'primary');
|
|
assert.equal(
|
|
'/v1/sys/replication/performance/primary/disable',
|
|
url,
|
|
'replication:performance primary:disable url OK'
|
|
);
|
|
|
|
adapter.replicationAction('disable', 'dr', 'secondary');
|
|
assert.equal('/v1/sys/replication/dr/secondary/disable', url, 'replication: drsecondary:disable url OK');
|
|
assert.equal('POST', method, 'replication:secondary:disable method OK');
|
|
adapter.replicationAction('disable', 'performance', 'secondary');
|
|
assert.equal(
|
|
'/v1/sys/replication/performance/secondary/disable',
|
|
url,
|
|
'replication: performance:disable url OK'
|
|
);
|
|
|
|
adapter.replicationAction('demote', 'dr', 'primary');
|
|
assert.equal('/v1/sys/replication/dr/primary/demote', url, 'replication: dr primary:demote url OK');
|
|
assert.equal('POST', method, 'replication:primary:demote method OK');
|
|
adapter.replicationAction('demote', 'performance', 'primary');
|
|
assert.equal(
|
|
'/v1/sys/replication/performance/primary/demote',
|
|
url,
|
|
'replication: performance primary:demote url OK'
|
|
);
|
|
|
|
adapter.replicationAction('promote', 'performance', 'secondary');
|
|
assert.equal('POST', method, 'replication:secondary:promote method OK');
|
|
assert.equal(
|
|
'/v1/sys/replication/performance/secondary/promote',
|
|
url,
|
|
'replication:performance secondary:promote url OK'
|
|
);
|
|
|
|
adapter.replicationDrPromote();
|
|
assert.equal('/v1/sys/replication/dr/secondary/promote', url, 'replication:dr secondary:promote url OK');
|
|
assert.equal('PUT', method, 'replication:dr secondary:promote method OK');
|
|
adapter.replicationDrPromote({}, { checkStatus: true });
|
|
assert.equal('/v1/sys/replication/dr/secondary/promote', url, 'replication:dr secondary:promote url OK');
|
|
assert.equal('GET', method, 'replication:dr secondary:promote method OK');
|
|
});
|
|
});
|