-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'opencadc:main' into main
- Loading branch information
Showing
18 changed files
with
237 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
## deployable containers have a semantic and build tag | ||
# version tag: major.minor.patch | ||
# build version tag: timestamp | ||
VER=0.23.0 | ||
VER=0.23.1 | ||
TAGS="${VER} ${VER}-$(date -u +"%Y%m%dT%H%M%S")" | ||
unset VER |
74 changes: 74 additions & 0 deletions
74
skaha/src/intTest/java/org/opencadc/skaha/RepositoryHostsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.opencadc.skaha; | ||
|
||
import ca.nrc.cadc.auth.AuthMethod; | ||
import ca.nrc.cadc.net.HttpGet; | ||
import ca.nrc.cadc.reg.Standards; | ||
import ca.nrc.cadc.reg.client.RegistryClient; | ||
import ca.nrc.cadc.util.Log4jInit; | ||
import ca.nrc.cadc.util.StringUtil; | ||
import java.io.ByteArrayOutputStream; | ||
import java.net.URL; | ||
import java.security.PrivilegedExceptionAction; | ||
import java.util.Arrays; | ||
import javax.security.auth.Subject; | ||
import org.apache.log4j.Level; | ||
import org.apache.log4j.Logger; | ||
import org.json.JSONArray; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class RepositoryHostsTest { | ||
private static final Logger log = Logger.getLogger(RepositoryHostsTest.class); | ||
|
||
static { | ||
Log4jInit.setLevel("org.opencadc.skaha", Level.INFO); | ||
} | ||
|
||
protected final URL repositoryURL; | ||
protected final Subject userSubject; | ||
|
||
public RepositoryHostsTest() throws Exception { | ||
final String configuredServiceEndpoint = System.getProperty("SKAHA_SERVICE_ENDPOINT"); | ||
if (StringUtil.hasText(configuredServiceEndpoint)) { | ||
repositoryURL = new URL(configuredServiceEndpoint); | ||
} else { | ||
final RegistryClient regClient = new RegistryClient(); | ||
final URL imageServiceURL = regClient.getServiceURL( | ||
SessionUtil.getSkahaServiceID(), Standards.PROC_SESSIONS_10, AuthMethod.TOKEN); | ||
repositoryURL = new URL(imageServiceURL.toExternalForm() + "/repository"); | ||
} | ||
log.info("sessions URL: " + repositoryURL); | ||
|
||
this.userSubject = SessionUtil.getCurrentUser(repositoryURL, false); | ||
} | ||
|
||
protected static String[] getRepositoryHosts(final URL serviceURLEndpoint) { | ||
final ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
final HttpGet get = new HttpGet(serviceURLEndpoint, out); | ||
get.run(); | ||
Assert.assertNull("get repository hosts error", get.getThrowable()); | ||
Assert.assertEquals("response code", 200, get.getResponseCode()); | ||
Assert.assertEquals("content-type", "application/json", get.getContentType()); | ||
final JSONArray jsonArray = new JSONArray(out.toString()); | ||
return jsonArray.toList().stream().map(Object::toString).toArray(String[]::new); | ||
} | ||
|
||
@Test | ||
public void testGetImageList() { | ||
try { | ||
Subject.doAs(this.userSubject, (PrivilegedExceptionAction<Object>) () -> { | ||
// should have at least one image | ||
final String[] repositoryHosts = RepositoryHostsTest.getRepositoryHosts(this.repositoryURL); | ||
Assert.assertNotEquals( | ||
"Should have at least one (" + Arrays.toString(repositoryHosts) + ")", | ||
0, | ||
repositoryHosts.length); | ||
return null; | ||
}); | ||
|
||
} catch (Exception t) { | ||
log.error("unexpected throwable", t); | ||
Assert.fail("unexpected throwable: " + t); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
skaha/src/main/java/org/opencadc/skaha/repository/GetAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.opencadc.skaha.repository; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStreamWriter; | ||
import java.io.Writer; | ||
import java.util.Arrays; | ||
import org.json.JSONWriter; | ||
import org.opencadc.skaha.SkahaAction; | ||
|
||
/** | ||
* Output the resource context information. | ||
* | ||
* @author majorb | ||
*/ | ||
public class GetAction extends SkahaAction { | ||
|
||
@Override | ||
public void doAction() throws Exception { | ||
initRequest(); | ||
final Writer writer = initWriter(); | ||
final JSONWriter jsonWriter = new JSONWriter(writer).array(); | ||
try { | ||
Arrays.stream(getHarborHosts()).forEach(jsonWriter::value); | ||
} finally { | ||
jsonWriter.endArray(); | ||
writer.flush(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void initRequest() throws Exception { | ||
super.initRequest(); | ||
} | ||
|
||
Writer initWriter() throws IOException { | ||
this.syncOutput.setHeader("content-type", "application/json"); | ||
return new OutputStreamWriter(syncOutput.getOutputStream()); | ||
} | ||
|
||
String[] getHarborHosts() { | ||
return this.harborHosts.toArray(new String[0]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.