Search in sources :

Example 1 with JedisOps

use of org.sagebionetworks.bridge.redis.JedisOps in project BridgeServer2 by Sage-Bionetworks.

the class CacheProviderTest method assertSession.

private void assertSession(String json) {
    JedisOps jedisOps = mock(JedisOps.class);
    when(jedisOps.get(TOKEN_TO_USER_ID.toString())).thenReturn(USER_ID);
    when(jedisOps.get(USER_ID_TO_SESSION.toString())).thenReturn(json);
    cacheProvider.setJedisOps(jedisOps);
    UserSession session = cacheProvider.getUserSession(DECRYPTED_SESSION_TOKEN);
    assertTrue(session.isAuthenticated());
    assertEquals(session.getEnvironment(), Environment.LOCAL);
    assertEquals(session.getSessionToken(), DECRYPTED_SESSION_TOKEN);
    assertEquals(session.getInternalSessionToken(), "4f0937a5-6ebf-451b-84bc-fbf649b9e93c");
    assertEquals(session.getId(), "6gq4jGXLmAxVbLLmVifKN4");
    assertEquals(session.getAppId(), TEST_APP_ID);
    StudyParticipant participant = session.getParticipant();
    assertEquals(participant.getFirstName(), "Bridge");
    assertEquals(participant.getLastName(), "IT");
    assertEquals(participant.getEmail(), "bridgeit@sagebase.org");
    assertEquals(participant.getSharingScope(), SharingScope.NO_SHARING);
    assertEquals(participant.getCreatedOn(), DateTime.parse("2016-04-21T16:48:22.386Z"));
    assertEquals(participant.getRoles(), Sets.newHashSet(Roles.ADMIN));
    assertEquals(participant.getLanguages(), ImmutableList.of("en", "fr"));
    assertEquals(participant.getExternalId(), "ABC");
    assertEquals(ENCRYPTOR.decrypt(ENCRYPTED_SESSION_TOKEN), participant.getHealthCode());
    SubpopulationGuid apiGuid = SubpopulationGuid.create(TEST_APP_ID);
    Map<SubpopulationGuid, ConsentStatus> consentStatuses = session.getConsentStatuses();
    ConsentStatus status = consentStatuses.get(apiGuid);
    assertEquals(status.getName(), "Default Consent Group");
    assertEquals(status.getSubpopulationGuid(), apiGuid.getGuid());
    assertTrue(status.getSignedMostRecentConsent());
    assertTrue(status.isRequired());
    assertFalse(status.isConsented());
}
Also used : JedisOps(org.sagebionetworks.bridge.redis.JedisOps) ConsentStatus(org.sagebionetworks.bridge.models.accounts.ConsentStatus) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) SubpopulationGuid(org.sagebionetworks.bridge.models.subpopulations.SubpopulationGuid) StudyParticipant(org.sagebionetworks.bridge.models.accounts.StudyParticipant)

Aggregations

ConsentStatus (org.sagebionetworks.bridge.models.accounts.ConsentStatus)1 StudyParticipant (org.sagebionetworks.bridge.models.accounts.StudyParticipant)1 UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)1 SubpopulationGuid (org.sagebionetworks.bridge.models.subpopulations.SubpopulationGuid)1 JedisOps (org.sagebionetworks.bridge.redis.JedisOps)1