mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
checking if jira login is successful
This commit is contained in:
@@ -39,6 +39,8 @@ import java.util.List;
|
||||
public class JiraRepository extends BaseRepositoryImpl {
|
||||
|
||||
private final static Logger LOG = Logger.getInstance("#com.intellij.tasks.jira.JiraRepository");
|
||||
public static final String LOGIN_FAILED_CHECK_YOUR_PERMISSIONS = "Login failed. Check your permissions.";
|
||||
|
||||
private boolean myJira4 = true;
|
||||
|
||||
/**
|
||||
@@ -160,6 +162,9 @@ public class JiraRepository extends BaseRepositoryImpl {
|
||||
if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_MOVED_TEMPORARILY) {
|
||||
throw new IOException("Can't login: " + statusCode + " (" + HttpStatus.getStatusText(statusCode) + ")");
|
||||
}
|
||||
if (statusCode == HttpStatus.SC_OK && new String(postMethod.getResponseBody(2000)).contains("\"loginSucceeded\":false")) {
|
||||
throw new IOException(LOGIN_FAILED_CHECK_YOUR_PERMISSIONS);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,14 @@ public class JiraIntegrationTest extends TaskManagerTestCase {
|
||||
assertFalse(issues[0].isClosed());
|
||||
}
|
||||
|
||||
public void testLogin() throws Exception {
|
||||
myRepository.setUsername("german");
|
||||
myRepository.setUsername("wrong password");
|
||||
Exception exception = myRepository.createCancellableConnection().call();
|
||||
assertNotNull(exception);
|
||||
assertEquals(JiraRepository.LOGIN_FAILED_CHECK_YOUR_PERMISSIONS, exception.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
Reference in New Issue
Block a user