diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2020-03-24 10:32:50 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2020-03-24 10:32:50 +0100 |
commit | 84a1c56ecbe8c8bd3705ea747584a98f5fa34147 (patch) | |
tree | b21cea4c3c9b361bceaf9f7023420737696a41cd | |
parent | 76a82eeed23094e0f2b70b1325115b8b1e521904 (diff) |
Support api key variable for signature based test framework controller client
-rw-r--r-- | hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java | 2 | ||||
-rw-r--r-- | tenant-auth/src/main/java/ai/vespa/hosted/auth/ApiAuthenticator.java | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java b/hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java index fd640bcc235..22c32cfa9ec 100644 --- a/hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java +++ b/hosted-api/src/main/java/ai/vespa/hosted/api/Properties.java @@ -52,7 +52,7 @@ public class Properties { return getNonBlankProperty("apiCertificateFile").map(Paths::get); } - /** Returns the actual private key as a string */ + /** Returns the actual private key as a string. */ public static Optional<String> apiKey() { return getNonBlankProperty("apiKey"); } diff --git a/tenant-auth/src/main/java/ai/vespa/hosted/auth/ApiAuthenticator.java b/tenant-auth/src/main/java/ai/vespa/hosted/auth/ApiAuthenticator.java index 82d859b08bd..55b3af93050 100644 --- a/tenant-auth/src/main/java/ai/vespa/hosted/auth/ApiAuthenticator.java +++ b/tenant-auth/src/main/java/ai/vespa/hosted/auth/ApiAuthenticator.java @@ -13,10 +13,12 @@ public class ApiAuthenticator implements ai.vespa.hosted.api.ApiAuthenticator { .map(certificateFile -> ControllerHttpClient.withKeyAndCertificate(Properties.apiEndpoint(), Properties.apiKeyFile(), certificateFile)) - .orElseGet(() -> - ControllerHttpClient.withSignatureKey(Properties.apiEndpoint(), - Properties.apiKeyFile(), - Properties.application())); + .or(() -> Properties.apiKey().map(apiKey -> ControllerHttpClient.withSignatureKey(Properties.apiEndpoint(), + apiKey, + Properties.application()))) + .orElseGet(() -> ControllerHttpClient.withSignatureKey(Properties.apiEndpoint(), + Properties.apiKeyFile(), + Properties.application())); } } |