Use http_password_url in GR-HTTP-PASSWORD when provided
Bug: Issue 5790 Change-Id: I9c64fe15c12dc91ff7addf14a7007775f24cf4fa
This commit is contained in:
@@ -48,13 +48,20 @@ limitations under the License.
|
||||
</style>
|
||||
<style include="gr-settings-styles"></style>
|
||||
<div class="gr-settings-styles">
|
||||
<section>
|
||||
<span class="title">Username</span>
|
||||
<span class="value">[[_username]]</span>
|
||||
</section>
|
||||
<gr-button
|
||||
id="generateButton"
|
||||
on-tap="_handleGenerateTap">Generate new password</gr-button>
|
||||
<div hidden$="[[_passwordUrl]]">
|
||||
<section>
|
||||
<span class="title">Username</span>
|
||||
<span class="value">[[_username]]</span>
|
||||
</section>
|
||||
<gr-button
|
||||
id="generateButton"
|
||||
on-tap="_handleGenerateTap">Generate new password</gr-button>
|
||||
</div>
|
||||
<span hidden$="[[!_passwordUrl]]">
|
||||
<a href="[[_passwordUrl]]" target="_blank" rel="noopener">
|
||||
Obtain password</a>
|
||||
(opens in a new tab)
|
||||
</span>
|
||||
</div>
|
||||
<gr-overlay
|
||||
id="generatedPasswordOverlay"
|
||||
|
||||
@@ -20,12 +20,21 @@
|
||||
properties: {
|
||||
_username: String,
|
||||
_generatedPassword: String,
|
||||
_passwordUrl: String,
|
||||
},
|
||||
|
||||
loadData: function() {
|
||||
return this.$.restAPI.getAccount().then(function(account) {
|
||||
var promises = [];
|
||||
|
||||
promises.push(this.$.restAPI.getAccount().then(function(account) {
|
||||
this._username = account.username;
|
||||
}.bind(this));
|
||||
}.bind(this)));
|
||||
|
||||
promises.push(this.$.restAPI.getConfig().then(function(info) {
|
||||
this._passwordUrl = info.auth.http_password_url || null;
|
||||
}.bind(this)));
|
||||
|
||||
return Promise.all(promises);
|
||||
},
|
||||
|
||||
_handleGenerateTap: function() {
|
||||
|
||||
@@ -35,13 +35,16 @@ limitations under the License.
|
||||
var element;
|
||||
var account;
|
||||
var password;
|
||||
var config;
|
||||
|
||||
setup(function(done) {
|
||||
account = {username: 'user name'};
|
||||
config = {auth: {}};
|
||||
password = 'the password';
|
||||
|
||||
stub('gr-rest-api-interface', {
|
||||
getAccount: function() { return Promise.resolve(account); },
|
||||
getConfig: function() { return Promise.resolve(config); },
|
||||
});
|
||||
|
||||
element = fixture('basic');
|
||||
@@ -72,6 +75,19 @@ limitations under the License.
|
||||
assert.equal(element._generatedPassword, nextPassword);
|
||||
});
|
||||
});
|
||||
|
||||
test('without http_password_url', function() {
|
||||
assert.isNull(element._passwordUrl);
|
||||
});
|
||||
|
||||
test('with http_password_url', function(done) {
|
||||
config.auth.http_password_url = 'http://example.com/';
|
||||
element.loadData().then(function() {
|
||||
assert.isNotNull(element._passwordUrl);
|
||||
assert.equal(element._passwordUrl, config.auth.http_password_url);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user