Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
meirish committed Jul 3, 2018
1 parent 53f5289 commit 94b69e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ui/app/components/auth-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default Ember.Component.extend(DEFAULTS, {
error: null,
});
let targetRoute = this.get('redirectTo') || 'vault.cluster';
let backend = this.get('selectedAuthBackend');
let backend = this.get('selectedAuthBackend') || {};
let path = get(backend, 'path') || this.get('customPath');
let backendMeta = BACKENDS.find(
b => get(b, 'type').toLowerCase() === get(backend, 'type').toLowerCase()
Expand Down
16 changes: 11 additions & 5 deletions ui/tests/integration/components/auth-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ const routerService = Ember.Service.extend({
transitionTo() {
return Ember.RSVP.resolve();
},
replaceWith() {
return Ember.RSVP.resolve();
},
});
moduleForComponent('auth-form', 'Integration | Component | auth form', {
integration: true,
beforeEach() {
Ember.getOwner(this).lookup('service:csp-event').attach();
component.setContext(this);
this.register('service:router', routerService);
this.inject.service('router');
},

afterEach() {
Expand All @@ -47,7 +52,8 @@ test('it renders error on CSP violation', function(assert) {
this.register('service:auth', authService);
this.inject.service('auth');
this.set('cluster', Ember.Object.create({ standby: true }));
this.render(hbs`{{auth-form cluster=cluster}}`);
this.set('selectedAuth', 'token');
this.render(hbs`{{auth-form cluster=cluster selectedAuth=selectedAuth}}`);
assert.equal(component.errorText, '');
component.login();
// because this is an ember-concurrency backed service,
Expand All @@ -72,7 +78,8 @@ test('it renders with vault style errors', function(assert) {
});

this.set('cluster', Ember.Object.create({}));
this.render(hbs`{{auth-form cluster=cluster}}`);
this.set('selectedAuth', 'token');
this.render(hbs`{{auth-form cluster=cluster selectedAuth=selectedAuth}}`);
return component.login().then(() => {
assert.equal(component.errorText, 'Error Authentication failed: Not allowed');
server.shutdown();
Expand All @@ -87,7 +94,8 @@ test('it renders AdapterError style errors', function(assert) {
});

this.set('cluster', Ember.Object.create({}));
this.render(hbs`{{auth-form cluster=cluster}}`);
this.set('selectedAuth', 'token');
this.render(hbs`{{auth-form cluster=cluster selectedAuth=selectedAuth}}`);
return component.login().then(() => {
assert.equal(component.errorText, 'Error Authentication failed: Bad Request');
server.shutdown();
Expand Down Expand Up @@ -137,9 +145,7 @@ test('it renders all the supported methods when no supported methods are present

test('it makes a request to unwrap if passed a wrappedToken and logs in', function(assert) {
this.register('service:auth', workingAuthService);
this.register('service:router', routerService);
this.inject.service('auth');
this.inject.service('router');
let authSpy = sinon.spy(this.get('auth'), 'authenticate');
let server = new Pretender(function() {
this.post('/v1/sys/wrapping/unwrap', () => {
Expand Down

0 comments on commit 94b69e8

Please sign in to comment.