Skip to content

Commit cc8d08c

Browse files
committed
Reset datarepo-clienttests - didn't work to use a single service account
1 parent f9c2158 commit cc8d08c

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

datarepo-clienttests/src/main/java/runner/config/ServiceAccountSpecification.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
public class ServiceAccountSpecification implements SpecificationInterface {
99
public String name;
10-
public String jsonKeyCredFilePath;
10+
public String jsonKeyDirectoryPath;
11+
public String jsonKeyFilename;
1112

1213
public File jsonKeyFile;
1314

1415
public static final String resourceDirectory = "serviceaccounts";
15-
public static final String keyCredFilePathEnvironmentVarName =
16-
"GOOGLE_APPLICATION_CREDENTIALS";
16+
public static final String keyDirectoryPathEnvironmentVarName =
17+
"TEST_RUNNER_SA_KEY_DIRECTORY_PATH";
1718

1819
ServiceAccountSpecification() {}
1920

@@ -33,20 +34,20 @@ public static ServiceAccountSpecification fromJSONFile(String resourceFileName)
3334
ServiceAccountSpecification serviceAccount =
3435
objectMapper.readValue(inputStream, ServiceAccountSpecification.class);
3536

36-
String credFilePathEnvVarOverride = readCredFilePathEnvironmentVariable();
37-
if (credFilePathEnvVarOverride != null) {
38-
serviceAccount.jsonKeyCredFilePath = credFilePathEnvVarOverride;
37+
String keyDirectoryPathEnvVarOverride = readKeyDirectoryPathEnvironmentVariable();
38+
if (keyDirectoryPathEnvVarOverride != null) {
39+
serviceAccount.jsonKeyDirectoryPath = keyDirectoryPathEnvVarOverride;
3940
}
4041

4142
return serviceAccount;
4243
}
4344

44-
protected static String readCredFilePathEnvironmentVariable() {
45-
// look for a full file path defined for the service account credentials
45+
protected static String readKeyDirectoryPathEnvironmentVariable() {
46+
// look for the service account JSON key file in a directory defined by, in order:
4647
// 1. environment variable
47-
// 2. service account jsonKeyCredFilePath property
48-
String keyCredFilePathEnvironmentVarValue = System.getenv(keyCredFilePathEnvironmentVarName);
49-
return keyCredFilePathEnvironmentVarValue;
48+
// 2. service account jsonKeyDirectoryPath property
49+
String keyDirectoryPathEnvironmentVarValue = System.getenv(keyDirectoryPathEnvironmentVarName);
50+
return keyDirectoryPathEnvironmentVarValue;
5051
}
5152

5253
/**
@@ -56,14 +57,19 @@ protected static String readCredFilePathEnvironmentVariable() {
5657
public void validate() {
5758
if (name == null || name.equals("")) {
5859
throw new IllegalArgumentException("Service account name cannot be empty");
59-
} else if (jsonKeyCredFilePath == null || jsonKeyCredFilePath.equals("")) {
60-
throw new IllegalArgumentException("JSON key file path cannot be empty");
60+
} else if (jsonKeyFilename == null || jsonKeyFilename.equals("")) {
61+
throw new IllegalArgumentException("JSON key file name cannot be empty");
62+
} else if (jsonKeyDirectoryPath == null || jsonKeyDirectoryPath.equals("")) {
63+
throw new IllegalArgumentException("JSON key directory path cannot be empty");
6164
}
6265

63-
jsonKeyFile = new File(jsonKeyCredFilePath);
66+
jsonKeyFile = new File(jsonKeyDirectoryPath, jsonKeyFilename);
6467
if (!jsonKeyFile.exists()) {
6568
throw new IllegalArgumentException(
66-
"JSON key file does not exist: (filePath)" + jsonKeyCredFilePath);
69+
"JSON key file does not exist: (directory)"
70+
+ jsonKeyDirectoryPath
71+
+ ", (filename)"
72+
+ jsonKeyFilename);
6773
}
6874
}
6975
}

datarepo-clienttests/src/main/resources/servers/staging.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"name": "ModularHelmChart",
1515
"parameters": ["https://raw.githubusercontent.com/broadinstitute/datarepo-helm-definitions/master/staging/datarepo-api.yaml"]
1616
},
17-
"testRunnerServiceAccountFile": "jade-k8-sa.json",
17+
"testRunnerServiceAccountFile": "staging-test-runner-sa.json",
1818
"skipDeployment": true,
1919
"skipKubernetes": true
2020
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"name": "[email protected]",
3-
"jsonKeyCredFilePath": "/tmp/jade-dev-account.json"
3+
"jsonKeyFilename": "jade-dev-account.json",
4+
"jsonKeyDirectoryPath": "/tmp"
45
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"name": "datarepo-jade-test-runner@terra-datarepo-staging.iam.gserviceaccount.com",
3-
"jsonKeyCredFilePath": "/tmp/staging-test-runner.json"
3+
"jsonKeyFilename": "staging-test-runner.json",
4+
"jsonKeyDirectoryPath": "/tmp"
45
}

0 commit comments

Comments
 (0)