Make sure token is set to blank if nothing is typed in settings
This commit is contained in:
parent
2aaacd3ff4
commit
4de710f0ec
|
@ -16,14 +16,18 @@ export default Service.extend({
|
|||
};
|
||||
},
|
||||
findAll: function(key) {
|
||||
return Promise.resolve({ token: get(this, 'storage').getItem('token') });
|
||||
const token = get(this, 'storage').getItem('token');
|
||||
return Promise.resolve({ token: token === null ? '' : token });
|
||||
},
|
||||
findBySlug: function(slug) {
|
||||
// TODO: Force localStorage to always be strings...
|
||||
// const value = get(this, 'storage').getItem(slug);
|
||||
return Promise.resolve(get(this, 'storage').getItem(slug));
|
||||
},
|
||||
persist: function(obj) {
|
||||
const storage = get(this, 'storage');
|
||||
Object.keys(obj).forEach((item, i) => {
|
||||
// TODO: ...everywhere
|
||||
storage.setItem(item, obj[item]);
|
||||
});
|
||||
return Promise.resolve(obj);
|
||||
|
|
15
ui-v2/tests/acceptance/settings/update.feature
Normal file
15
ui-v2/tests/acceptance/settings/update.feature
Normal file
|
@ -0,0 +1,15 @@
|
|||
@setupApplicationTest
|
||||
Feature: settings / update: Update Settings
|
||||
In order to authenticate with an ACL token
|
||||
As a user
|
||||
I need to be able to add my token via the UI
|
||||
Scenario: I click Save without actually typing anything
|
||||
Given 1 datacenter model with the value "datacenter"
|
||||
When I visit the settings page
|
||||
Then the url should be /settings
|
||||
And I submit
|
||||
Then I have settings like yaml
|
||||
---
|
||||
token: ''
|
||||
---
|
||||
|
10
ui-v2/tests/acceptance/steps/settings/update-steps.js
Normal file
10
ui-v2/tests/acceptance/steps/settings/update-steps.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import steps from '../steps';
|
||||
|
||||
// step definitions that are shared between features should be moved to the
|
||||
// tests/acceptance/steps/steps.js file
|
||||
|
||||
export default function(assert) {
|
||||
return steps(assert).then('I should find a file', function() {
|
||||
assert.ok(true, this.step);
|
||||
});
|
||||
}
|
|
@ -12,7 +12,7 @@ Feature: token headers
|
|||
headers:
|
||||
X-Consul-Token: ''
|
||||
---
|
||||
Scenario: Set a token and then navigate to the index page
|
||||
Scenario: Set the token to [Token] and then navigate to the index page
|
||||
Given 1 datacenter model with the value "datacenter"
|
||||
When I visit the settings page
|
||||
Then the url should be /settings
|
||||
|
|
|
@ -242,6 +242,15 @@ export default function(assert) {
|
|||
`Expected ${num} ${model}s with ${property} set to "${value}", saw ${len}`
|
||||
);
|
||||
})
|
||||
.then('I have settings like yaml\n$yaml', function(data) {
|
||||
// TODO: Inject this
|
||||
const settings = window.localStorage;
|
||||
Object.keys(data).forEach(function(prop) {
|
||||
const actual = settings.getItem(prop);
|
||||
const expected = data[prop];
|
||||
assert.strictEqual(actual, expected, `Expected settings to be ${expected} was ${actual}`);
|
||||
});
|
||||
})
|
||||
.then('I see $property on the $component like yaml\n$yaml', function(
|
||||
property,
|
||||
component,
|
||||
|
|
Loading…
Reference in a new issue