Fix hiding http credentials if using a different auth type.
Change-Id: Iea9d10d953efb6da5f7a439c3571ba7149c72d08
This commit is contained in:
@@ -398,10 +398,12 @@ limitations under the License.
|
||||
disabled="[[!_computeAddEmailButtonEnabled(_newEmail, _addingEmail)]]"
|
||||
on-tap="_handleAddEmailButton">Send verification</gr-button>
|
||||
</fieldset>
|
||||
<h2 id="HTTPCredentials">HTTP Credentials</h2>
|
||||
<fieldset>
|
||||
<gr-http-password id="httpPass"></gr-http-password>
|
||||
</fieldset>
|
||||
<div hidden$="[[!_showHttpAuth(_serverConfig)]]">
|
||||
<h2 id="HTTPCredentials">HTTP Credentials</h2>
|
||||
<fieldset>
|
||||
<gr-http-password id="httpPass"></gr-http-password>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div hidden$="[[!_serverConfig.sshd]]">
|
||||
<h2
|
||||
id="SSHKeys"
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
const ABSOLUTE_URL_PATTERN = /^https?:/;
|
||||
const TRAILING_SLASH_PATTERN = /\/$/;
|
||||
|
||||
const HTTP_AUTH = [
|
||||
'HTTP',
|
||||
'HTTP_LDAP',
|
||||
];
|
||||
|
||||
Polymer({
|
||||
is: 'gr-settings-view',
|
||||
|
||||
@@ -395,5 +400,15 @@
|
||||
|
||||
return base + GERRIT_DOCS_FILTER_PATH;
|
||||
},
|
||||
|
||||
_showHttpAuth(config) {
|
||||
if (config && config.auth &&
|
||||
config.auth.git_basic_auth_policy) {
|
||||
return HTTP_AUTH.includes(
|
||||
config.auth.git_basic_auth_policy.toUpperCase());
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -468,6 +468,46 @@ limitations under the License.
|
||||
assert.isTrue(overlayOpen.called);
|
||||
});
|
||||
|
||||
test('_showHttpAuth', () => {
|
||||
let serverConfig;
|
||||
|
||||
serverConfig = {
|
||||
auth: {
|
||||
git_basic_auth_policy: 'HTTP',
|
||||
},
|
||||
};
|
||||
|
||||
assert.isTrue(element._showHttpAuth(serverConfig));
|
||||
|
||||
serverConfig = {
|
||||
auth: {
|
||||
git_basic_auth_policy: 'HTTP_LDAP',
|
||||
},
|
||||
};
|
||||
|
||||
assert.isTrue(element._showHttpAuth(serverConfig));
|
||||
|
||||
serverConfig = {
|
||||
auth: {
|
||||
git_basic_auth_policy: 'LDAP',
|
||||
},
|
||||
};
|
||||
|
||||
assert.isFalse(element._showHttpAuth(serverConfig));
|
||||
|
||||
serverConfig = {
|
||||
auth: {
|
||||
git_basic_auth_policy: 'OAUTH',
|
||||
},
|
||||
};
|
||||
|
||||
assert.isFalse(element._showHttpAuth(serverConfig));
|
||||
|
||||
serverConfig = {};
|
||||
|
||||
assert.isFalse(element._showHttpAuth(serverConfig));
|
||||
});
|
||||
|
||||
suite('_getFilterDocsLink', () => {
|
||||
test('with http: docs base URL', () => {
|
||||
const base = 'http://example.com/';
|
||||
|
||||
Reference in New Issue
Block a user