Skip to content

Commit

Permalink
Merge branch 'develop' into TASK-2095
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfeSanahuja committed Nov 15, 2023
2 parents 768606f + baa3631 commit ebaff42
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: opencb/java-common-libs/.github/workflows/build-java-app-workflow.yml@develop
with:
maven_opts: -DCELLBASE.WAR.NAME=cellbase -P default-config-test

test:
uses: ./.github/workflows/test-analysis.yml
needs: build
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/test-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ jobs:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Start MongoDB v6.0
uses: supercharge/[email protected]
with:
mongodb-version: 6.0
mongodb-replica-set: rs-test
- name: K8s Tunnel MongoDB
run: |
wget https://dl.k8s.io/release/v1.28.2/bin/linux/amd64/kubectl
chmod +x ./kubectl
echo "${{ secrets.AZURE_KUBE_CONFIG }}" > admin.conf
./kubectl -n cellbase-db port-forward services/cellbase-rs0-svc 27017:27017 --kubeconfig ./admin.conf &
- name: Install dependencies branches
run: |
if [ -f "./.github/workflows/scripts/get_same_branch.sh" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,13 @@ public class ApiKeyCommandOptions {
@ParametersDelegate
public CommonCommandOptions commonOptions = commonCommandOptions;

@Parameter(names = {"--create-api-key"}, description = "Create an API key with the licensed data sources indicated separated by"
+ " commas and optionally the expiration date: source[:dd/mm/yyyy]. e.g.: cosmic:31/01/2025,hgmd. In addition the"
+ " 'organization' has to be specified", arity = 1)
public String createWithDataSources;
@Parameter(names = {"--create-api-key"}, description = "Create an API key", arity = 0)
public boolean createApiKey;

@Parameter(names = {"--licensed-data-sources"}, description = "Use this parameter in conjunction with --create-api-key to specify the"
+ " licensed data sources separated by commas and optionally the expiration date: source[:dd/mm/yyyy]. e.g.:"
+ " cosmic:31/01/2025,hgmd", arity = 1)
public String dataSources;

@Parameter(names = {"--expiration"}, description = "Use this parameter in conjunction with --create-api-key to specify the"
+ " expiration date in format dd/mm/yyyy, e.g.: 03/09/2030", arity = 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public ApiKeyCommandExecutor(AdminCliOptionsParser.ApiKeyCommandOptions apiKeyCo
this.apiKeyCommandOptions = apiKeyCommandOptions;
}


/**
* Execute one of the selected actions according to the input parameters.
*/
Expand All @@ -60,7 +59,7 @@ public void execute() {
ApiKeyManager apiKeyManager = new ApiKeyManager(SignatureAlgorithm.HS256.getValue(), key);

try {
if (StringUtils.isNotEmpty(apiKeyCommandOptions.createWithDataSources)) {
if (apiKeyCommandOptions.createApiKey) {
// Create the API key JWT payload
ApiKeyJwtPayload payload = new ApiKeyJwtPayload();
payload.setSubject(apiKeyCommandOptions.organization);
Expand All @@ -69,7 +68,7 @@ public void execute() {
if (apiKeyCommandOptions.expiration != null) {
payload.setExpiration(parseDate(apiKeyCommandOptions.expiration));
}
payload.setSources(parseSources(apiKeyCommandOptions.createWithDataSources));
payload.setSources(parseSources(apiKeyCommandOptions.dataSources));
payload.setQuota(new ApiKeyQuota(apiKeyCommandOptions.maxNumQueries));

// Create API key
Expand All @@ -86,20 +85,23 @@ public void execute() {
}

private void checkParameters() {
if (StringUtils.isNotEmpty(apiKeyCommandOptions.createWithDataSources)
&& StringUtils.isNotEmpty(apiKeyCommandOptions.apiKeyToView)) {
throw new IllegalArgumentException("Please, select only one of these input parameters: create or view");
if (apiKeyCommandOptions.createApiKey && StringUtils.isNotEmpty(apiKeyCommandOptions.apiKeyToView)) {
throw new IllegalArgumentException("Please, select only one of these input parameters: create-api-key or view-api-key");
}
if (StringUtils.isEmpty(apiKeyCommandOptions.createWithDataSources)
&& StringUtils.isEmpty(apiKeyCommandOptions.apiKeyToView)) {
throw new IllegalArgumentException("Please, it is mandatory to select one of these input parameters: create or view");
if (!apiKeyCommandOptions.createApiKey && StringUtils.isEmpty(apiKeyCommandOptions.apiKeyToView)) {
throw new IllegalArgumentException("Please, it is mandatory to select one of these input parameters: create-api-key or"
+ " view-api-key");
}

// Check create parameters
if (StringUtils.isNotEmpty(apiKeyCommandOptions.createWithDataSources)) {
if (apiKeyCommandOptions.createApiKey) {
if (StringUtils.isEmpty(apiKeyCommandOptions.organization)) {
throw new IllegalArgumentException("Missing organization");
}
if (StringUtils.isEmpty(apiKeyCommandOptions.dataSources) && apiKeyCommandOptions.maxNumQueries <= 0) {
throw new IllegalArgumentException("Please, it is mandatory to specify either the licensed data sources, the maximum number"
+ " of queries, or both");
}
}

if (StringUtils.isEmpty(configuration.getSecretKey())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.opencb.cellbase.client.rest;

import org.apache.avro.specific.SpecificRecordBase;
import org.apache.commons.collections4.CollectionUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -105,6 +106,10 @@ private void orderVariantAnnotation(VariantAnnotation va) {
c.getProteinVariantAnnotation().getFeatures().sort(Comparator.comparing(SpecificRecordBase::hashCode));
}
});

if (CollectionUtils.isNotEmpty(va.getFunctionalScore())) {
va.getFunctionalScore().sort(Comparator.comparing(SpecificRecordBase::hashCode));
}
}

// @Test
Expand Down
7 changes: 4 additions & 3 deletions cellbase-lib/src/test/resources/configuration.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ secretKey: "xPacig89igHSieEnveJEi4KCfdEslhmssC3vui1JJQGgDQ0y8v"
databases:
mongodb:
host: localhost:27017
user: ''
password: ''
user: 'cellbase'
password: 'cellbase'
options:
authenticationDatabase: ''
authenticationDatabase: 'admin'
authenticationMechanism: 'SCRAM-SHA-256'
readPreference: ''
replicaSet: ''
connectionsPerHost: 20
Expand Down

0 comments on commit ebaff42

Please sign in to comment.