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

Examples of com.atlassian.jira.rest.client.api.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


  private final JiraRestClientFactory clientFactory = new AsynchronousJiraRestClientFactory();

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

  }
View Full Code Here

    });
  }

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

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

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

    final Session sessionAfterFailedLogin = client.getSessionClient().getCurrentSession().claim();
    assertTrue(sessionAfterFailedLogin.getLoginInfo().getLastFailedLoginDate().isAfter(lastFailedLoginDate));
    assertTrue(sessionAfterFailedLogin.getLoginInfo().getLastFailedLoginDate().isAfter(now));
  }
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"));
    Assert.assertEquals(TestConstants.USER_ADMIN_BASIC_DEPRECATED.getSelf(), session.getUserUri());
    Assert.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

TOP

Related Classes of com.atlassian.jira.rest.client.api.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.