IDEA-128824 Use cookie authentication only for JIRA on-Demand

This commit is contained in:
Mikhail Golubev
2014-09-02 18:13:51 +04:00
parent 344fa63b10
commit 8d4c32052a
2 changed files with 16 additions and 10 deletions
@@ -227,12 +227,17 @@ public class JiraRepository extends BaseRepositoryImpl {
HttpClient client = getHttpClient();
// Fix for https://jetbrains.zendesk.com/agent/#/tickets/24566
// See https://confluence.atlassian.com/display/ONDEMANDKB/Getting+randomly+logged+out+of+OnDemand for details
if (BASIC_AUTH_ONLY) {
// IDEA-128824, IDEA-128706 Use cookie authentication only for JIRA on-Demand
// TODO Make JiraVersion more suitable for such checks
final boolean isJiraOnDemand = StringUtil.notNullize(myJiraVersion).contains("OD");
if (isJiraOnDemand) {
LOG.info("Connecting to JIRA on-Demand. Cookie authentication is enabled unless 'tasks.jira.basic.auth.only' VM flag is used.");
}
if (BASIC_AUTH_ONLY || !isJiraOnDemand) {
// to override persisted settings
setUseHttpAuthentication(true);
}
else {
// disable subsequent basic authorization attempts if user already was authenticated
boolean enableBasicAuthentication = !(isRestApiSupported() && containsCookie(client, AUTH_COOKIE_NAME));
if (enableBasicAuthentication != isUseHttpAuthentication()) {
LOG.info("Basic authentication for subsequent requests was " + (enableBasicAuthentication ? "enabled" : "disabled"));
@@ -119,14 +119,15 @@ public class JiraIntegrationTest extends TaskManagerTestCase {
}
}
public void testBasicAuthenticationDisabling() throws Exception {
assertTrue("Basic authentication should be enabled at first", myRepository.isUseHttpAuthentication());
myRepository.findTask("PRJONE-1");
assertFalse("Basic authentication should be disabled once JSESSIONID cookie was received", myRepository.isUseHttpAuthentication());
HttpClient client = myRepository.getHttpClient();
assertFalse(client.getParams().isAuthenticationPreemptive());
assertNull(client.getState().getCredentials(AuthScope.ANY));
}
// TODO move to on-Demand-specific tests
//public void testBasicAuthenticationDisabling() throws Exception {
// assertTrue("Basic authentication should be enabled at first", myRepository.isUseHttpAuthentication());
// myRepository.findTask("PRJONE-1");
// assertFalse("Basic authentication should be disabled once JSESSIONID cookie was received", myRepository.isUseHttpAuthentication());
// HttpClient client = myRepository.getHttpClient();
// assertFalse(client.getParams().isAuthenticationPreemptive());
// assertNull(client.getState().getCredentials(AuthScope.ANY));
//}
public void testSetTaskState() throws Exception {
changeStateAndCheck(JIRA_4_TEST_SERVER_URL, "PRJONE-8");