open-vault/ui/tests/unit/adapters/tools-test.js
Matthew Irish f38a50b6b2
UI - unauthed login methods (#4854)
* fetch auth methods when going to the auth route and pass them to the auth form component

* add boolean editType for form-fields

* look in the data hash in the serializer

* remove renderInPlace for info-tooltips as it does something goofy with widths

* add new fields for auth methods

* fix console refresh command on routes that use lazyPaginatedQuery

* add wrapped_token param that logs you in via the token backend and show other backends if your list contains supported ones

* handle casing when looking up supported backends

* change listingVisibility to match the new API

* move wrapped_token up to the vault route level so it works from the app root
2018-07-05 13:28:12 -05:00

58 lines
2.1 KiB
JavaScript

import { moduleFor, test } from 'ember-qunit';
import Ember from 'ember';
moduleFor('adapter:tools', 'Unit | Adapter | tools', {
needs: ['service:auth', 'service:flash-messages'],
});
test('wrapping api urls', function(assert) {
let url, method, options;
let adapter = this.subject({
ajax: (...args) => {
[url, method, options] = args;
return Ember.RSVP.resolve();
},
});
let clientToken;
let data = { foo: 'bar' };
adapter.toolAction('wrap', data, { wrapTTL: '30m' });
assert.equal('/v1/sys/wrapping/wrap', url, 'wrapping:wrap url OK');
assert.equal('POST', method, 'wrapping:wrap method OK');
assert.deepEqual({ data: data, wrapTTL: '30m', clientToken }, options, 'wrapping:wrap options OK');
data = { token: 'token' };
adapter.toolAction('lookup', data);
assert.equal('/v1/sys/wrapping/lookup', url, 'wrapping:lookup url OK');
assert.equal('POST', method, 'wrapping:lookup method OK');
assert.deepEqual({ data, clientToken }, options, 'wrapping:lookup options OK');
adapter.toolAction('unwrap', data);
assert.equal('/v1/sys/wrapping/unwrap', url, 'wrapping:unwrap url OK');
assert.equal('POST', method, 'wrapping:unwrap method OK');
assert.deepEqual({ data, clientToken }, options, 'wrapping:unwrap options OK');
adapter.toolAction('rewrap', data);
assert.equal('/v1/sys/wrapping/rewrap', url, 'wrapping:rewrap url OK');
assert.equal('POST', method, 'wrapping:rewrap method OK');
assert.deepEqual({ data, clientToken }, options, 'wrapping:rewrap options OK');
});
test('tools api urls', function(assert) {
let url, method;
let adapter = this.subject({
ajax: (...args) => {
[url, method] = args;
return Ember.RSVP.resolve();
},
});
adapter.toolAction('hash', { input: 'someBase64' });
assert.equal(url, '/v1/sys/tools/hash', 'sys tools hash: url OK');
assert.equal('POST', method, 'sys tools hash: method OK');
adapter.toolAction('random', { bytes: '32' });
assert.equal(url, '/v1/sys/tools/random', 'sys tools random: url OK');
assert.equal('POST', method, 'sys tools random: method OK');
});