-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix by returning apiPath from the model (#10122)
* fix by returning apiPath from the model * remove unused service * be more specific of when setting dynamicApiPath * new acceptance test for auth list * remove unused policy * udpate comment
- Loading branch information
1 parent
0668169
commit e371ded
Showing
5 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,39 @@ | ||
import { assign } from '@ember/polyfills'; | ||
import ApplicationAdapter from './application'; | ||
import { task } from 'ember-concurrency'; | ||
|
||
export default ApplicationAdapter.extend({ | ||
namespace: 'v1', | ||
urlForItem() {}, | ||
dynamicApiPath: '', | ||
getDynamicApiPath: task(function*(id) { | ||
let result = yield this.store.peekRecord('auth-method', id); | ||
this.dynamicApiPath = result.apiPath; | ||
return; | ||
}), | ||
|
||
fetchByQuery(store, query, isList) { | ||
fetchByQuery: task(function*(store, query, isList) { | ||
const { id } = query; | ||
let data = {}; | ||
if (isList) { | ||
data.list = true; | ||
yield this.getDynamicApiPath.perform(id); | ||
} | ||
|
||
return this.ajax(this.urlForItem(id, isList), 'GET', { data }).then(resp => { | ||
return this.ajax(this.urlForItem(id, isList, this.dynamicApiPath), 'GET', { data }).then(resp => { | ||
const data = { | ||
id, | ||
method: id, | ||
}; | ||
return assign({}, resp, data); | ||
}); | ||
}, | ||
}), | ||
|
||
query(store, type, query) { | ||
return this.fetchByQuery(store, query, true); | ||
return this.fetchByQuery.perform(store, query, true); | ||
}, | ||
|
||
queryRecord(store, type, query) { | ||
return this.fetchByQuery(store, query); | ||
return this.fetchByQuery.perform(store, query); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { click, fillIn, settled, visit } from '@ember/test-helpers'; | ||
import { module, test } from 'qunit'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
import authPage from 'vault/tests/pages/auth'; | ||
import logout from 'vault/tests/pages/logout'; | ||
import enablePage from 'vault/tests/pages/settings/auth/enable'; | ||
|
||
module('Acceptance | userpass secret backend', function(hooks) { | ||
setupApplicationTest(hooks); | ||
|
||
hooks.beforeEach(function() { | ||
return authPage.login(); | ||
}); | ||
|
||
hooks.afterEach(function() { | ||
return logout.visit(); | ||
}); | ||
|
||
test('userpass backend', async function(assert) { | ||
let n = Math.random(); | ||
const path1 = `userpass-${++n}`; | ||
const path2 = `userpass-${++n}`; | ||
const user1 = 'user1'; | ||
const user2 = 'user2'; | ||
|
||
// enable the first userpass method with one username | ||
await enablePage.enable('userpass', path1); | ||
await click('[data-test-save-config="true"]'); | ||
await visit(`/vault/access/${path1}/item/user/create`); | ||
await fillIn('[data-test-input="username"]', user1); | ||
await fillIn('[data-test-textarea]', user1); | ||
await click('[data-test-save-config="true"]'); | ||
|
||
// enable the first userpass method with one username | ||
await visit(`/vault/settings/auth/enable`); | ||
await click('[data-test-mount-type="userpass"]'); | ||
await click('[data-test-mount-next]'); | ||
await fillIn('[data-test-input="path"]', path2); | ||
await click('[data-test-mount-submit="true"]'); | ||
await click('[data-test-save-config="true"]'); | ||
await settled(); | ||
await click(`[data-test-auth-backend-link="${path2}"]`); | ||
await click('[data-test-create="user"]'); | ||
await fillIn('[data-test-input="username"]', user2); | ||
await fillIn('[data-test-textarea]', user2); | ||
await click('[data-test-save-config="true"]'); | ||
|
||
//confirming that the user was created. There was a bug where the apiPath was not being updated when toggling between auth routes | ||
assert | ||
.dom('[data-test-list-item-content]') | ||
.hasText(user2, 'user just created shows in current auth list'); | ||
|
||
//confirm that the auth method 1 shows the user1. There was a bug where it was not updated the list when toggling between auth routes | ||
await visit(`/vault/access/${path1}/item/user`); | ||
assert | ||
.dom('[data-test-list-item-content]') | ||
.hasText(user1, 'first user created shows in current auth list'); | ||
}); | ||
}); |