Merge branch 'stable-2.16'

* stable-2.16:
  Fix hiding http credentials if using a different auth type.

Change-Id: I98d9c3a96b0fbbc8128ddf77220fc04cf357c592
This commit is contained in:
Paladox
2019-03-19 17:29:01 +00:00
3 changed files with 61 additions and 4 deletions

View File

@@ -384,10 +384,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"

View File

@@ -40,6 +40,11 @@
const RELOAD_MESSAGE = 'Reloading...';
const HTTP_AUTH = [
'HTTP',
'HTTP_LDAP',
];
Polymer({
is: 'gr-settings-view',
@@ -413,5 +418,15 @@
window.location.reload();
}, 1);
},
_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;
},
});
})();

View File

@@ -407,6 +407,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/';