Conversation
- Implemented batch secret retrieval methods in ResourceClient, Variables, and ResourceProvider. - Enhanced Endpoints class to support batch retrieval URI. - Added comprehensive unit tests for batch secret retrieval in ResourceClientTest.
|
Ignore close, I mixed up tabs and closed the wrong PR. |
|
I also created a manual full integration test of this code but wasn't sure if it fit in the repo. I can add it if wanted. |
|
Thank you for the PR! We've added it to our backlog to review. Tracking internally as CNJR-13117. |
| private final URI authnUri; | ||
| private final URI secretsUri; | ||
|
|
||
| public Endpoints(final URI authnUri, final URI secretsUri){ |
There was a problem hiding this comment.
Removing public constructors from Endpoints is technically a breaking change for anyone who instantiated it directly. Since Endpoints is public, consumers had no guardrail telling them not to use it.
Even though Endpoints is not the documented primary
API, it is a public class in a published package — so any external consumer instantiating it directly(for whatever reason) will get a compile error after upgrading.
The old constructors should stay, adjusted for the new functionality.
| this(applianceUrl, account, applianceUrl + "/authn"); | ||
| } | ||
|
|
||
| public Endpoints(String authnUri, String secretsUri){ |
There was a problem hiding this comment.
Same thing as with the other constructor.
| * @param variableIds the variable IDs to retrieve | ||
| * @return a map of variable ID to secret value | ||
| */ | ||
| public Map<String, String> retrieveBatchSecrets(String... variableIds) { |
There was a problem hiding this comment.
This seems like an unnecessary shortcut. This method is already defined in the variables and should be accessed through there.
Summary
Adds support for the Conjur Batch Secret Retrieval API (
GET /secrets?variable_ids=...) to the Java SDK.Closes #126
Changes
New: Batch Secret Retrieval
ResourceProvider: AddedretrieveBatchSecrets(String... variableIds)as a default interface methodResourceClient: Full implementation — builds thevariable_idsquery parameter with proper percent-encoding (slashes,@,+,&, spaces as%20), parses the JSON map response via Gson, and strips the{account}:variable:prefix from response keysVariables/Conjur: Expose the batch method through the existing delegation chainRefactored: Endpoints
Endpoints(String applianceUrl, String account)— all service URIs are derived from these two valuesEndpoints(String applianceUrl, String account, String authnUrl)for custom authenticators (LDAP, OIDC, etc.)getBatchSecretsUri()returning{applianceUrl}/secretsfromSystemProperties()andfromCredentials()simplified to thin wrappersgetServiceUri()static helper that re-read system propertiesTests
ResourceClientTestusing Mockito to mock the JAX-RS client stack@,+,&, spaces), all error codes (401/403/404/422), null/empty args, deeply nested paths, response order preservation,buildBatchQueryParamhelper, single secret retrieval, and Endpoints URI derivationAPI Usage
Testing
mvn test)