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());
}
Aggregations