Skip to content

Conversation

wallrj-cyberark
Copy link
Member

@wallrj-cyberark wallrj-cyberark commented Aug 27, 2025

Similar to #699, I want all the cyberark API wrappers to take an httpClient as an injected dependency rather than them each instantiating their own client. This way the http client can be created once, with sensible defaults and roundtrippers, and supplied to all the API wrappers.

  • Replaced NewCyberArkClient with New to simplify client initialization
    by removing certificate pool handling and relying on an injected HTTP client.
  • Updated CyberArkClient to use httpClient instead of client for clarity.
  • Refactored MockDataUploadServer to return both server URL and HTTP client,
    improving test setup and reducing boilerplate.
  • Removed unused imports and redundant code in dataupload_test.go and mock.go.

Follow up PRs

@wallrj-cyberark wallrj-cyberark force-pushed the VC-43403-dataupload-client branch from 6c2e839 to a49662f Compare August 27, 2025 13:49
@wallrj-cyberark wallrj-cyberark changed the title Refactor the CyberArk dataupload client to take an HTTP client [VC-43403] Refactor the CyberArk dataupload client to take an HTTP client Aug 27, 2025
@wallrj-cyberark wallrj-cyberark force-pushed the VC-43403-dataupload-client branch from a49662f to 5bd316d Compare August 27, 2025 15:49
@wallrj-cyberark wallrj-cyberark force-pushed the VC-43403-servicediscovery-client branch 5 times, most recently from 25eccd6 to e61ad7a Compare August 27, 2025 16:31
…ability

- Replaced `NewCyberArkClient` with `New` for a cleaner API
- Removed dependency on `x509.CertPool` and `transport.NewDebuggingRoundTripper`
- Updated `CyberArkClient` to use `http.Client` directly
- Refactored tests to use `MockDataUploadServer` with `testing.TB` for better cleanup
- Simplified mock server setup and logging for improved maintainability

Signed-off-by: Richard Wall <[email protected]>
@wallrj-cyberark wallrj-cyberark force-pushed the VC-43403-dataupload-client branch from 5bd316d to 3fa015d Compare August 27, 2025 16:48
Base automatically changed from VC-43403-servicediscovery-client to master August 28, 2025 08:20

serviceURL := fmt.Sprintf("https://%s%s%s.%s", subdomain, separator, discoveryContextServiceName, platformDomain)
// TODO(wallrj): get this from the servicediscovery API instead.
inventoryAPI := fmt.Sprintf("https://%s.inventory.%s", subdomain, platformDomain)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO is implemented in a followup PR: #701


_ "embed"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

embed was never used in this mock. Other mocks load sample API responses from files, but this mock doesn't...yet.

@@ -6,4 +6,4 @@ import (

type CyberArkClient = dataupload.CyberArkClient

var NewCyberArkClient = dataupload.NewCyberArkClient
var NewCyberArkClient = dataupload.New
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #696 I will introduce a MachineHub / CyberArk outputter (data publisher) and put it in this file.

@wallrj-cyberark wallrj-cyberark marked this pull request as ready for review August 28, 2025 09:06
@wallrj-cyberark wallrj-cyberark merged commit 99dc0aa into master Aug 28, 2025
2 checks passed
@wallrj-cyberark wallrj-cyberark deleted the VC-43403-dataupload-client branch August 28, 2025 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants