use of io.dockstore.webservice.DockstoreWebserviceConfiguration in project dockstore by dockstore.
the class PublicStateManagerIT method setupManager.
@BeforeClass
public static void setupManager() {
DockstoreWebserviceConfiguration config = new DockstoreWebserviceConfiguration();
config.getEsConfiguration().setHostname("localhost");
config.getEsConfiguration().setPort(9200);
PublicStateManagerIT.manager = PublicStateManager.getInstance();
manager.setConfig(config);
}
use of io.dockstore.webservice.DockstoreWebserviceConfiguration in project dockstore by dockstore.
the class SamPermissionsImplTest method setup.
@Before
public void setup() {
ownerPolicy = new AccessPolicyResponseEntry();
ownerPolicy.setPolicyName(SamConstants.OWNER_POLICY);
AccessPolicyMembership accessPolicyMembership = new AccessPolicyMembership();
accessPolicyMembership.setRoles(Collections.singletonList(SamConstants.OWNER_POLICY));
accessPolicyMembership.setMemberEmails(Collections.singletonList("jdoe@ucsc.edu"));
ownerPolicy.setPolicy(accessPolicyMembership);
writerPolicy = new AccessPolicyResponseEntry();
writerPolicy.setPolicyName(SamConstants.WRITE_POLICY);
AccessPolicyMembership writerMembership = new AccessPolicyMembership();
writerMembership.setRoles(Collections.singletonList(SamConstants.WRITE_POLICY));
writerMembership.setMemberEmails(Collections.singletonList(JANE_DOE_GMAIL_COM));
writerPolicy.setPolicy(writerMembership);
AccessPolicyResponseEntry readerPolicy = new AccessPolicyResponseEntry();
readerPolicy.setPolicyName(SamConstants.READ_POLICY);
AccessPolicyMembership readerMembership = new AccessPolicyMembership();
readerMembership.setRoles(Collections.singletonList(SamConstants.READ_POLICY));
readerMembership.setMemberEmails(Collections.singletonList(JANE_DOE_GMAIL_COM));
readerPolicy.setPolicy(readerMembership);
TokenDAO tokenDAO = Mockito.mock(TokenDAO.class);
DockstoreWebserviceConfiguration configMock = Mockito.mock(DockstoreWebserviceConfiguration.class);
when(configMock.getSamConfiguration()).thenReturn(new DockstoreWebserviceConfiguration.SamConfiguration());
samPermissionsImpl = Mockito.spy(new SamPermissionsImpl(tokenDAO, configMock));
doReturn(Optional.of("my token")).when(samPermissionsImpl).googleAccessToken(userMock);
doReturn(Mockito.mock(Token.class)).when(samPermissionsImpl).googleToken(userMock);
resourcesApiMock = Mockito.mock(ResourcesApi.class);
ApiClient apiClient = Mockito.mock(ApiClient.class);
when(apiClient.escapeString(ArgumentMatchers.anyString())).thenAnswer(invocation -> invocation.getArgument(0));
when(resourcesApiMock.getApiClient()).thenReturn(apiClient);
when(samPermissionsImpl.getResourcesApi(userMock)).thenReturn(resourcesApiMock);
workflowInstance = Mockito.mock(Workflow.class);
when(workflowInstance.getWorkflowPath()).thenReturn("foo");
ownerPermission = new Permission();
ownerPermission.setEmail("jdoe@ucsc.edu");
ownerPermission.setRole(Role.OWNER);
Assert.assertThat(samPermissionsImpl.accessPolicyResponseEntryToUserPermissions(Collections.singletonList(ownerPolicy)), CoreMatchers.is(Collections.singletonList(ownerPermission)));
writerPermission = new Permission();
writerPermission.setEmail(JANE_DOE_GMAIL_COM);
writerPermission.setRole(Role.WRITER);
readerPermission = new Permission();
readerPermission.setEmail(JANE_DOE_GMAIL_COM);
readerPermission.setRole(Role.READER);
AccessPolicyMembership readerAccessPolicyMembership = new AccessPolicyMembership();
readerAccessPolicyResponseEntry = new AccessPolicyResponseEntry();
readerAccessPolicyResponseEntry.setPolicy(readerAccessPolicyMembership);
readerAccessPolicyResponseEntry.setPolicyName(SamConstants.READ_POLICY);
readerAccessPolicyResponseEntry.getPolicy().addRolesItem(SamConstants.READ_POLICY);
readerAccessPolicyResponseEntry.getPolicy().addMemberEmailsItem(JANE_DOE_GMAIL_COM);
final User.Profile profile = new User.Profile();
profile.email = JANE_DOE_GMAIL_COM;
final Map<String, User.Profile> map = new HashMap<>();
map.put(TokenType.GOOGLE_COM.toString(), profile);
when(userMock.getUserProfiles()).thenReturn(map);
}
use of io.dockstore.webservice.DockstoreWebserviceConfiguration in project dockstore by dockstore.
the class GoogleHelperTest method isValidAudience.
@Test
public void isValidAudience() {
final DockstoreWebserviceConfiguration config = new DockstoreWebserviceConfiguration();
config.setGoogleClientID(AUDIENCE1);
config.getExternalGoogleClientIdPrefixes().add(EXTERNAL_PREFIX);
GoogleHelper.setConfig(config);
final Tokeninfo tokeninfo = Mockito.mock(Tokeninfo.class);
when(tokeninfo.getAudience()).thenReturn(AUDIENCE1).thenReturn(EXTERNAL_AUDIENCE).thenReturn(INVALID_AUDIENCE);
Assert.assertTrue(GoogleHelper.isValidAudience(tokeninfo));
Assert.assertTrue(GoogleHelper.isValidAudience(tokeninfo));
Assert.assertFalse(GoogleHelper.isValidAudience(tokeninfo));
}
use of io.dockstore.webservice.DockstoreWebserviceConfiguration in project dockstore by dockstore.
the class PublicStateManagerIT method setupManager.
@BeforeClass
public static void setupManager() {
DockstoreWebserviceConfiguration config = new DockstoreWebserviceConfiguration();
config.getEsConfiguration().setHostname("localhost");
config.getEsConfiguration().setPort(9200);
PublicStateManagerIT.manager = PublicStateManager.getInstance();
manager.setConfig(config);
}
Aggregations