Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update actions. #12

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,23 @@

name: Storage UI build

on:
on:
pull_request:
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Build with Gradle
run: ./gradlew -i clean build test
- name: Docker build
run: docker build -t opencadc/storage:SNAPSHOT .

test:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Check docker-compose
run: docker-compose -v
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
with:
arguments: clean build test
- name: Docker build
run: docker build -t opencadc/storage:SNAPSHOT .
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

package net.canfar.storage.web.resources;

import net.canfar.storage.web.config.StorageConfiguration;
import net.canfar.storage.web.restlet.JSONRepresentation;

import org.apache.logging.log4j.LogManager;
Expand All @@ -91,6 +92,13 @@
public class GroupNameServerResource extends SecureServerResource {
private static final Logger LOGGER = LogManager.getLogger(GroupNameServerResource.class);

public GroupNameServerResource() {
super();
}

GroupNameServerResource(StorageConfiguration storageConfiguration) {
super(storageConfiguration);
}

@Get("json")
public Representation getGroupNames() throws Exception {
Expand Down Expand Up @@ -121,7 +129,7 @@ final List<String> queryGroupNames(final Subject voSpaceUser) throws PrivilegedA
return Subject.doAs(voSpaceUser, (PrivilegedExceptionAction<List<String>>) () -> {
if (storageConfiguration.isOIDCConfigured()) {
LOGGER.debug("Getting only Group Names that user is a member of.");
final IvoaGroupClient ivoaGroupClient = new IvoaGroupClient();
final IvoaGroupClient ivoaGroupClient = getIvoaGroupClient();
return ivoaGroupClient.getMemberships(storageConfiguration.getGMSServiceURI())
.stream()
.map(GroupURI::getName)
Expand All @@ -132,4 +140,8 @@ final List<String> queryGroupNames(final Subject voSpaceUser) throws PrivilegedA
}
});
}

IvoaGroupClient getIvoaGroupClient() {
return new IvoaGroupClient();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,13 @@

package net.canfar.storage.web.resources;

import ca.nrc.cadc.ac.client.GMSClient;
import ca.nrc.cadc.accesscontrol.AccessControlClient;
import ca.nrc.cadc.auth.AuthMethod;
import ca.nrc.cadc.auth.AuthenticationUtil;
import ca.nrc.cadc.auth.AuthorizationToken;
import ca.nrc.cadc.auth.AuthorizationTokenPrincipal;
import ca.nrc.cadc.auth.IdentityManager;
import ca.nrc.cadc.auth.SSOCookieCredential;
import ca.nrc.cadc.net.NetUtil;
import ca.nrc.cadc.reg.client.RegistryClient;
import net.canfar.storage.web.config.StorageConfiguration;
import net.canfar.storage.web.config.VOSpaceServiceConfigManager;
Expand Down Expand Up @@ -210,10 +208,6 @@ Client getOIDCClient() throws IOException {
return this.storageConfiguration.getOIDCClient();
}

GMSClient getGMSClient() {
return storageConfiguration.getGMSClient();
}

AccessControlClient getAccessControlClient() {
return storageConfiguration.getAccessControlClient();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@
*/
package net.canfar.storage.web.resources;

import ca.nrc.cadc.ac.client.GMSClient;
import net.canfar.storage.web.config.StorageConfiguration;
import net.canfar.storage.web.restlet.JSONRepresentation;
import net.canfar.storage.web.restlet.StorageApplication;
import ca.nrc.cadc.reg.client.RegistryClient;
import org.json.JSONArray;
import org.json.JSONWriter;
Expand All @@ -78,21 +77,19 @@
import static org.junit.Assert.*;

import org.mockito.Mockito;
import org.restlet.Context;
import org.opencadc.gms.IvoaGroupClient;
import org.restlet.Response;

import javax.security.auth.Subject;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class GroupNameServerResourceTest extends AbstractServerResourceTest<GroupNameServerResource> {

@Test
public void getGroupNames() throws Exception {

final List<String> groupList = new ArrayList<>();
groupList.add("CHIMPS");
groupList.add("A-TEAM");
Expand All @@ -101,7 +98,12 @@ public void getGroupNames() throws Exception {

Mockito.when(mockGMSClient.getGroupNames()).thenReturn(groupList);

testSubject = new GroupNameServerResource() {
final StorageConfiguration storageConfiguration = Mockito.mock(StorageConfiguration.class);

Mockito.when(storageConfiguration.isOIDCConfigured()).thenReturn(false);
Mockito.when(storageConfiguration.getGMSClient()).thenReturn(mockGMSClient);

testSubject = new GroupNameServerResource(storageConfiguration) {
@Override
RegistryClient getRegistryClient() {
return mockRegistryClient;
Expand All @@ -113,8 +115,8 @@ Subject getCurrentSubject() {
}

@Override
GMSClient getGMSClient() {
return mockGMSClient;
IvoaGroupClient getIvoaGroupClient() {
return null;
}

/**
Expand Down Expand Up @@ -143,6 +145,8 @@ public Response getResponse() {

assertEquals("Wrong list of items.", dataList, groupList);

Mockito.verify(storageConfiguration, Mockito.times(1)).isOIDCConfigured();
Mockito.verify(storageConfiguration, Mockito.times(1)).getGMSClient();
Mockito.verify(mockGMSClient, Mockito.atMostOnce()).getGroupNames();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ Subject getCurrentSubject() {
return new Subject();
}

@Override
protected StorageConfiguration getStorageConfiguration() {
return mockStorageConfiguration;
}

@Override
protected Client getOIDCClient() {
return mockOIDCConfiguration;
Expand Down
Loading