Package com.atlassian.jira.rest.client.domain

Examples of com.atlassian.jira.rest.client.domain.Session


  @Override
  public Session parse(JSONObject json) throws JSONException {
    final URI userUri = JsonParseUtil.getSelfUri(json);
    final String username = json.getString("name");
    final LoginInfo loginInfo = loginInfoJsonParser.parse(json.getJSONObject("loginInfo"));
    return new Session(userUri, username, loginInfo);
  }
View Full Code Here


@Restore(TestConstants.DEFAULT_JIRA_DUMP_FILE)
public class JerseySessionRestClientTest extends AbstractJerseyRestClientTest {

  @Test
  public void testValidSession() {
    final Session session = client.getSessionClient().getCurrentSession(new NullProgressMonitor());
    assertEquals(ADMIN_USERNAME, session.getUsername());

  }
View Full Code Here

    });
  }

  @Test
  public void testGetCurrentSession() throws Exception {
    final Session session = client.getSessionClient().getCurrentSession(new NullProgressMonitor());
    assertEquals(ADMIN_USERNAME, session.getUsername());

    // that is not a mistake - username and the password for this user is the same
    client = new JerseyJiraRestClient(jiraUri, new BasicHttpAuthenticationHandler(TestConstants.USER1.getName(),
        TestConstants.USER1.getName()));
    final Session session2 = client.getSessionClient().getCurrentSession(new NullProgressMonitor());
    assertEquals(TestConstants.USER1.getName(), session2.getUsername());
    final DateTime lastFailedLoginDate = session2.getLoginInfo().getLastFailedLoginDate();

    final JerseyJiraRestClient client2 = new JerseyJiraRestClient(jiraUri, new BasicHttpAuthenticationHandler(TestConstants.USER1.getName(),
        "bad-password"));
    final DateTime now = new DateTime();
    TestUtil.assertErrorCode(401, new Runnable() {
      @Override
      public void run() {
        client2.getSessionClient().getCurrentSession(new NullProgressMonitor());
      }
    });
    while (!new DateTime().isAfter(lastFailedLoginDate)) {
      Thread.sleep(20);
    }

    final Session sessionAfterFailedLogin = client.getSessionClient().getCurrentSession(new NullProgressMonitor());
    assertTrue(sessionAfterFailedLogin.getLoginInfo().getLastFailedLoginDate().isAfter(lastFailedLoginDate));
    assertTrue(sessionAfterFailedLogin.getLoginInfo().getLastFailedLoginDate().isAfter(now));
  }
View Full Code Here

  }
*/

  @Test
  public void testGetCurrentSession() {
    final Session session = client.getSessionClient().getCurrentSession(new NullProgressMonitor());
    assertEquals(ADMIN_USERNAME, session.getUsername());
  }
View Full Code Here

public class SessionJsonParserTest {
  @Test
  public void testParse() throws Exception {
    SessionJsonParser parser = new SessionJsonParser();
    final Session session = parser.parse(ResourceUtil.getJsonObjectFromResource("/json/session/valid.json"));
    assertEquals(TestConstants.USER_ADMIN.getSelf(), session.getUserUri());
    assertEquals("admin", session.getUsername());
    assertEquals(new LoginInfo(12, 413, TestUtil.toDateTime("2010-09-14T16:15:47.554+0200"),
        TestUtil.toDateTime("2010-09-14T16:48:33.002+0200")), session.getLoginInfo());
  }
View Full Code Here

    });

  }

  private String getLoggedUsername(ProgressMonitor progressMonitor) {
    final Session session = sessionRestClient.getCurrentSession(progressMonitor);
    return session.getUsername();
  }
View Full Code Here

    });

  }

  private String getLoggedUsername(ProgressMonitor progressMonitor) {
    final Session session = sessionRestClient.getCurrentSession(progressMonitor);
    return session.getUsername();
  }
View Full Code Here

  @Override
  public Session parse(JSONObject json) throws JSONException {
    final URI userUri = JsonParseUtil.getSelfUri(json);
    final String username = json.getString("name");
    final LoginInfo loginInfo = loginInfoJsonParser.parse(json.getJSONObject("loginInfo"));
    return new Session(userUri, username, loginInfo);
  }
View Full Code Here

    });

  }

  private String getLoggedUsername(ProgressMonitor progressMonitor) {
    final Session session = sessionRestClient.getCurrentSession(progressMonitor);
    return session.getUsername();
  }
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.domain.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.