Skip to content

Commit e094aca

Browse files
committed
SK-1802 Renamed github secret
1 parent 8b1e558 commit e094aca

30 files changed

+143
-80
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}
2424

2525
- name: Build & Run tests with Maven
26-
run: mvn -B package -DTEST_VAULT_ID=${{ secrets.TEST_VAULT_ID }} -DTEST_VAULT_URL=${{ secrets.TEST_VAULT_URL }} -DTEST_SKYFLOW_ID=${{ secrets.TEST_SKYFLOW_ID }} -DTEST_TOKEN=${{ secrets.TEST_TOKEN }} -DTEST_CREDENTIALS=${{ secrets.TEST_CREDENTIALS_FILE_STRING }} -DTEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} -DTEST_HUNDRED_TOKEN=${{ secrets.TEST_HUNDRED_TOKEN }} -f pom.xml
26+
run: mvn -B package -DTEST_VAULT_ID=${{ secrets.TEST_VAULT_ID }} -DTEST_VAULT_URL=${{ secrets.TEST_VAULT_URL }} -DTEST_SKYFLOW_ID=${{ secrets.TEST_SKYFLOW_ID }} -DTEST_TOKEN=${{ secrets.TEST_TOKEN }} -DTEST_CREDENTIALS=${{ secrets.TEST_CREDENTIALS_FILE_STRING }} -DTEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} -DTEST_REUSABLE_TOKEN=${{ secrets.TEST_REUSABLE_TOKEN }} -f pom.xml
2727

2828
- name: Codecov
2929
uses: codecov/codecov-action@v2.1.0

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
touch .env
3838
echo SKYFLOW_CREDENTIALS=${{ secrets.SKYFLOW_CREDENTIALS }} >> .env
3939
echo TEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} >> .env
40-
echo TEST_HUNDRED_TOKEN=${{ secrets.TEST_HUNDRED_TOKEN }} >> .env
40+
echo TEST_REUSABLE_TOKEN=${{ secrets.TEST_REUSABLE_TOKEN }} >> .env
4141
4242
- name: Build & Run tests with Maven
4343
run: mvn -B package -DTEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} -DTEST_DATA_CREDENTIALS_FILE=${{ secrets.TEST_DATA_CREDENTIALS_FILE }} -f pom.xml

.github/workflows/shared-build-and-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
touch .env
9090
echo SKYFLOW_CREDENTIALS=${{ secrets.SKYFLOW_CREDENTIALS }} >> .env
9191
echo TEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} >> .env
92-
echo TEST_HUNDRED_TOKEN=${{ secrets.TEST_HUNDRED_TOKEN }} >> .env
92+
echo TEST_REUSABLE_TOKEN=${{ secrets.TEST_REUSABLE_TOKEN }} >> .env
9393
9494
- name: Create credentials json
9595
id: create-json

src/main/java/com/skyflow/ConnectionClient.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ protected void updateConnectionConfig(ConnectionConfig connectionConfig) throws
4141
}
4242

4343
protected void setBearerToken() throws SkyflowException {
44+
prioritiseCredentials();
4445
Validations.validateCredentials(this.finalCredentials);
4546
if (this.finalCredentials.getApiKey() != null) {
4647
setApiKey();
@@ -62,6 +63,7 @@ private void setApiKey() {
6263

6364
private void prioritiseCredentials() throws SkyflowException {
6465
try {
66+
Credentials original = this.finalCredentials;
6567
if (this.connectionConfig.getCredentials() != null) {
6668
this.finalCredentials = this.connectionConfig.getCredentials();
6769
} else if (this.commonCredentials != null) {
@@ -77,8 +79,10 @@ private void prioritiseCredentials() throws SkyflowException {
7779
this.finalCredentials.setCredentialsString(sysCredentials);
7880
}
7981
}
80-
token = null;
81-
apiKey = null;
82+
if (original != null && !original.equals(this.finalCredentials)) {
83+
token = null;
84+
apiKey = null;
85+
}
8286
} catch (DotenvException e) {
8387
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(),
8488
ErrorMessage.EmptyCredentials.getMessage());

src/main/java/com/skyflow/VaultClient.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ protected V1TokenizePayload getTokenizePayload(TokenizeRequest request) {
169169
}
170170

171171
protected void setBearerToken() throws SkyflowException {
172+
prioritiseCredentials();
172173
Validations.validateCredentials(this.finalCredentials);
173174
if (this.finalCredentials.getApiKey() != null) {
174175
setApiKey();
@@ -200,6 +201,7 @@ private void updateVaultURL() {
200201

201202
private void prioritiseCredentials() throws SkyflowException {
202203
try {
204+
Credentials original = this.finalCredentials;
203205
if (this.vaultConfig.getCredentials() != null) {
204206
this.finalCredentials = this.vaultConfig.getCredentials();
205207
} else if (this.commonCredentials != null) {
@@ -215,8 +217,10 @@ private void prioritiseCredentials() throws SkyflowException {
215217
this.finalCredentials.setCredentialsString(sysCredentials);
216218
}
217219
}
218-
token = null;
219-
apiKey = null;
220+
if (original != null && !original.equals(this.finalCredentials)) {
221+
token = null;
222+
apiKey = null;
223+
}
220224
} catch (DotenvException e) {
221225
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(),
222226
ErrorMessage.EmptyCredentials.getMessage());

src/main/java/com/skyflow/serviceaccount/util/BearerToken.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private static V1GetAuthTokenResponse generateBearerTokenFromCredentials(
5555
) throws SkyflowException {
5656
LogUtil.printInfoLog(InfoLogs.GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_TRIGGERED.getLog());
5757
try {
58-
if (credentialsFile == null || !credentialsFile.isFile()) {
58+
if (credentialsFile == null) {
5959
LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE.getLog());
6060
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidCredentials.getMessage());
6161
}
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
package com.skyflow.serviceaccount.util;
22

3+
import com.google.gson.Gson;
34
import com.skyflow.utils.Constants;
45

56
public class SignedDataTokenResponse {
67
private static final String prefix = Constants.SIGNED_DATA_TOKEN_PREFIX;
7-
private final String dataToken;
8-
private final String signedDataToken;
8+
private final String token;
9+
private final String signedToken;
910

10-
public SignedDataTokenResponse(String dataToken, String signedDataToken) {
11-
this.dataToken = dataToken;
12-
this.signedDataToken = new StringBuilder(prefix).append(signedDataToken).toString();
11+
public SignedDataTokenResponse(String token, String signedToken) {
12+
this.token = token;
13+
this.signedToken = new StringBuilder(prefix).append(signedToken).toString();
14+
}
15+
16+
public String getToken() {
17+
return token;
18+
}
19+
20+
public String getSignedToken() {
21+
return signedToken;
1322
}
1423

1524
@Override
1625
public String toString() {
17-
return "{" +
18-
"\n\t\"dataToken\":\"" + this.dataToken + "\"," +
19-
"\n\t\"signedDataToken\":\"" + this.signedDataToken + "\"," +
20-
"\n}";
26+
Gson gson = new Gson();
27+
return gson.toJson(this);
2128
}
2229
}

src/main/java/com/skyflow/serviceaccount/util/SignedDataTokens.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private static List<SignedDataTokenResponse> generateSignedTokenFromCredentialsF
5050
LogUtil.printInfoLog(InfoLogs.GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_FILE_TRIGGERED.getLog());
5151
List<SignedDataTokenResponse> responseToken;
5252
try {
53-
if (credentialsFile == null || !credentialsFile.isFile()) {
53+
if (credentialsFile == null) {
5454
LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE.getLog());
5555
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.InvalidCredentials.getMessage());
5656
}

src/main/java/com/skyflow/utils/validations/Validations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ public static void validateDeleteRequest(DeleteRequest deleteRequest) throws Sky
621621
} else {
622622
for (int index = 0; index < ids.size(); index++) {
623623
String id = ids.get(index);
624-
if (id.trim().isEmpty()) {
624+
if (id == null || id.trim().isEmpty()) {
625625
LogUtil.printErrorLog(Utils.parameterizedString(
626626
ErrorLogs.EMPTY_OR_NULL_ID_IN_IDS.getLog(),
627627
InterfaceName.DELETE.getName(), Integer.toString(index)

src/main/java/com/skyflow/vault/controller/ConnectionController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public InvokeConnectionResponse invoke(InvokeConnectionRequest invokeConnectionR
4242
Map<String, String> headers = new HashMap<>();
4343

4444
Map<String, String> requestHeaders = invokeConnectionRequest.getRequestHeaders();
45-
if (requestHeaders != null && requestHeaders.containsKey("requestHeader")) {
45+
if (requestHeaders != null) {
4646
headers = Utils.constructConnectionHeadersMap(invokeConnectionRequest.getRequestHeaders());
4747
}
4848
if (!headers.containsKey(Constants.SDK_AUTH_HEADER_KEY)) {
4949
headers.put(Constants.SDK_AUTH_HEADER_KEY, token == null ? apiKey : token);
50-
headers.put(Constants.SDK_METRICS_HEADER_KEY, Utils.getMetrics().toString());
5150
}
51+
headers.put(Constants.SDK_METRICS_HEADER_KEY, Utils.getMetrics().toString());
5252

5353
RequestMethod requestMethod = invokeConnectionRequest.getMethod();
5454
JsonObject requestBody = null;

0 commit comments

Comments
 (0)