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

Feature/2385/config #2401

Merged
merged 5 commits into from
Apr 23, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import io.swagger.client.api.MetadataApi;
import io.swagger.client.api.UsersApi;
import io.swagger.client.api.WorkflowsApi;
import io.swagger.client.model.Config;
import io.swagger.client.model.DockstoreTool;
import io.swagger.client.model.Entry;
import io.swagger.client.model.MetadataV1;
Expand Down Expand Up @@ -803,6 +804,17 @@ public void testUploadZip() {
Assert.assertEquals(1, updatedWorkflow.getWorkflowVersions().size());
}

/**
* Test that the config endpoint doesn't fail and validates one random property
*/
@Test
public void testConfig() {
final ApiClient webClient = getWebClient();
final MetadataApi metadataApi = new MetadataApi(webClient);
final Config config = metadataApi.getConfig();
Assert.assertEquals("read:org,user:email", config.getGitHubScope());
}

/**
* Tests workflow sharing/permissions.
*
Expand Down
29 changes: 29 additions & 0 deletions dockstore-integration-testing/src/test/resources/dockstore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,32 @@ logging:
timeZone: UTC
target: stdout
logFormat: # TODO

uiConfig:
# Must end with a slash
discourseUrl: https://discuss.dockstore.org/
dnaStackImportUrl: https://app.dnastack.com/#/app/workflow/import/dockstore
fireCloudImportUrl: https://portal.firecloud.org/#import/dockstore
dnaNexusImportUrl: https://platform.dnanexus.com/panx/tools/import-workflow
terraImportUrl: https://app.terra.bio/#import-tool/dockstore

gitHubAuthUrl: https://github.com/login/oauth/authorize
gitHubRedirectPath: /auth/github.com
gitHubScope: read:org,user:email

quayIoAuthUrl: https://quay.io/oauth/authorize
quayIoRedirectPath: /auth/quay.io
quayIoScope: repo:read,user:read

bitBucketAuthUrl: https://bitbucket.org/site/oauth2/authorize

gitlabAuthUrl: https://gitlab.com/oauth/authorize
gitlabRedirectPath: /auth/gitlab.com
gitlabScope: api

googleScope: profile email
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space separated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's how it is in dockstore.model.ts


cwlVisualizerUri: https://view.commonwl.org

enableLaunchWithFireCloud: true

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class DockstoreWebserviceConfiguration extends Configuration {
private String quayClientID;

@NotEmpty
private List<String> githubClientID;
private String githubClientID;

@NotEmpty
private String googleClientID;
Expand All @@ -82,7 +82,7 @@ public class DockstoreWebserviceConfiguration extends Configuration {
private String githubRedirectURI;

@NotEmpty
private List<String> githubClientSecret;
private String githubClientSecret;

@NotEmpty
private String googleRedirectURI;
Expand All @@ -105,6 +105,10 @@ public class DockstoreWebserviceConfiguration extends Configuration {

private List<String> externalGoogleClientIdPrefixes = new ArrayList<>();

@Valid
@NotNull
private UIConfig uiConfig;

@JsonProperty("database")
public DataSourceFactory getDataSourceFactory() {
return database;
Expand Down Expand Up @@ -183,15 +187,15 @@ public void setHttpClientConfiguration(HttpClientConfiguration newHttpClient) {
*/
@JsonProperty
@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
public List<String> getGithubClientID() {
public String getGithubClientID() {
return githubClientID;
}

/**
* @param githubClientID the githubClientID to set
*/
@JsonProperty
public void setGithubClientID(List<String> githubClientID) {
public void setGithubClientID(String githubClientID) {
this.githubClientID = githubClientID;
}

Expand All @@ -216,15 +220,15 @@ public void setGithubRedirectURI(String githubRedirectURI) {
*/
@JsonProperty
@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
public List<String> getGithubClientSecret() {
public String getGithubClientSecret() {
return githubClientSecret;
}

/**
* @param githubClientSecret the githubClientSecret to set
*/
@JsonProperty
public void setGithubClientSecret(List<String> githubClientSecret) {
public void setGithubClientSecret(String githubClientSecret) {
this.githubClientSecret = githubClientSecret;
}

Expand Down Expand Up @@ -378,6 +382,11 @@ public void setLimitConfig(LimitConfig limitConfig) {
this.limitConfig = limitConfig;
}

@JsonProperty
public UIConfig getUiConfig() {
return uiConfig;
}

/**
* This config defines values that define the webservice from the outside world.
* Most notably, for swagger. But also to configure generated RSS paths and TRS paths
Expand Down Expand Up @@ -489,4 +498,186 @@ public void setWorkflowVersionLimit(int workflowVersionLimit) {
this.workflowVersionLimit = workflowVersionLimit;
}
}

/**
* A subset of properties returned to the UI. Only a subset because some properties that will
* be used by the UI are also used by the web service and predate the existences of this class.
*/
public static class UIConfig {

/**
* Must end with a slash
*/
private String discourseUrl;

private String dnaStackImportUrl;
private String fireCloudImportUrl;
private String dnaNexusImportUrl;
private String terraImportUrl;

private String gitHubAuthUrl;
private String gitHubRedirectPath;
private String gitHubScope;

private String quayIoAuthUrl;
private String quayIoRedirectPath;
private String quayIoScope;

private String bitBucketAuthUrl;

private String gitlabAuthUrl;
private String gitlabRedirectPath;
private String gitlabScope;

private String googleScope;

private String cwlVisualizerUri;

private boolean enableLaunchWithFireCloud;


public String getDiscourseUrl() {
return discourseUrl;
}

public void setDiscourseUrl(String discourseUrl) {
this.discourseUrl = discourseUrl;
}

public String getDnaStackImportUrl() {
return dnaStackImportUrl;
}

public void setDnaStackImportUrl(String dnaStackImportUrl) {
this.dnaStackImportUrl = dnaStackImportUrl;
}

public String getFireCloudImportUrl() {
return fireCloudImportUrl;
}

public void setFireCloudImportUrl(String fireCloudImportUrl) {
this.fireCloudImportUrl = fireCloudImportUrl;
}

public String getDnaNexusImportUrl() {
return dnaNexusImportUrl;
}

public void setDnaNexusImportUrl(String dnaNexusImportUrl) {
this.dnaNexusImportUrl = dnaNexusImportUrl;
}

public String getTerraImportUrl() {
return terraImportUrl;
}

public void setTerraImportUrl(String terraImportUrl) {
this.terraImportUrl = terraImportUrl;
}

public String getGitHubAuthUrl() {
return gitHubAuthUrl;
}

public void setGitHubAuthUrl(String gitHubAuthUrl) {
this.gitHubAuthUrl = gitHubAuthUrl;
}

public String getGitHubRedirectPath() {
return gitHubRedirectPath;
}

public void setGitHubRedirectPath(String gitHubRedirectPath) {
this.gitHubRedirectPath = gitHubRedirectPath;
}

public String getGitHubScope() {
return gitHubScope;
}

public void setGitHubScope(String gitHubScope) {
this.gitHubScope = gitHubScope;
}

public String getQuayIoAuthUrl() {
return quayIoAuthUrl;
}

public void setQuayIoAuthUrl(String quayIoAuthUrl) {
this.quayIoAuthUrl = quayIoAuthUrl;
}

public String getQuayIoRedirectPath() {
return quayIoRedirectPath;
}

public void setQuayIoRedirectPath(String quayIoRedirectPath) {
this.quayIoRedirectPath = quayIoRedirectPath;
}

public String getQuayIoScope() {
return quayIoScope;
}

public void setQuayIoScope(String quayIoScope) {
this.quayIoScope = quayIoScope;
}

public String getBitBucketAuthUrl() {
return bitBucketAuthUrl;
}

public void setBitBucketAuthUrl(String bitBucketAuthUrl) {
this.bitBucketAuthUrl = bitBucketAuthUrl;
}

public String getGitlabAuthUrl() {
return gitlabAuthUrl;
}

public void setGitlabAuthUrl(String gitlabAuthUrl) {
this.gitlabAuthUrl = gitlabAuthUrl;
}

public String getGitlabRedirectPath() {
return gitlabRedirectPath;
}

public void setGitlabRedirectPath(String gitlabRedirectPath) {
this.gitlabRedirectPath = gitlabRedirectPath;
}

public String getGitlabScope() {
return gitlabScope;
}

public void setGitlabScope(String gitlabScope) {
this.gitlabScope = gitlabScope;
}

public String getGoogleScope() {
return googleScope;
}

public void setGoogleScope(String googleScope) {
this.googleScope = googleScope;
}

public String getCwlVisualizerUri() {
return cwlVisualizerUri;
}

public void setCwlVisualizerUri(String cwlVisualizerUri) {
this.cwlVisualizerUri = cwlVisualizerUri;
}

public boolean isEnableLaunchWithFireCloud() {
return enableLaunchWithFireCloud;
}

public void setEnableLaunchWithFireCloud(boolean enableLaunchWithFireCloud) {
this.enableLaunchWithFireCloud = enableLaunchWithFireCloud;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package io.dockstore.webservice.api;

import java.lang.reflect.InvocationTargetException;

import io.dockstore.webservice.DockstoreWebserviceConfiguration;
import io.swagger.annotations.ApiModel;
import org.apache.commons.beanutils.BeanUtils;

@ApiModel(description = "Configuration information for UI clients of the Dockstore webservice.")
public final class Config extends DockstoreWebserviceConfiguration.UIConfig {

/**
* Properties that aren't in UIConfig
*/

private String githubClientId;
private String quayIoClientId;
private String bitBucketClientId;
private String gitlabClientId;
private String googleClientId;


private Config() {
}

public static Config fromWebConfig(DockstoreWebserviceConfiguration webConfig)
throws InvocationTargetException, IllegalAccessException {
final Config config = new Config();
config.githubClientId = webConfig.getGithubClientID();
config.quayIoClientId = webConfig.getQuayClientID();
config.bitBucketClientId = webConfig.getBitbucketClientID();
config.gitlabClientId = webConfig.getGitlabClientID();
config.googleClientId = webConfig.getGoogleClientID();
BeanUtils.copyProperties(config, webConfig.getUiConfig());
return config;
}

public String getGithubClientId() {
return githubClientId;
}

public String getQuayIoClientId() {
return quayIoClientId;
}

public String getBitBucketClientId() {
return bitBucketClientId;
}

public String getGitlabClientId() {
return gitlabClientId;
}

public String getGoogleClientId() {
return googleClientId;
}

}