Skip to content

[VC-43753] CyberArk Discovery and Context: Use sha3 checksum in snapshot-links API request #686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2025

Conversation

wallrj-cyberark
Copy link
Contributor

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

The integration test was failing because the request body format for the snapshot-links API has been changed, to accept a sha3 checksum instead of a sha256 checksum.
I've updated the dataupload client accordingly.

Part of: https://venafi.atlassian.net/browse/VC-43753

Related PRs

  1. 🟢 [VC-43753] CyberArk Discovery and Context: Use sha3 checksum in snapshot-links API request #686
  2. [VC-43753] CyberArk Discovery and Context: Upload data in the JSON format required by the API #684
  3. [VC-43753] CyberArk Discovery and Context: Use a namespaces datagatherer to get the cluster ID #687

Testing

Before:

$ go test -v ./pkg/internal/cyberark/dataupload/... -run Real
warning: both GOPATH and GOROOT are the same directory (/home/richard/go); see https://go.dev/wiki/InstallTroubleshooting
=== RUN   TestPostDataReadingsWithOptionsWithRealAPI
    identity.go:330: I0813 17:07:34.740886] made successful request to StartAuthentication source="Identity.doStartAuthentication" summary="NewPackage"
    identity.go:446: I0813 17:07:35.184892] successfully completed AdvanceAuthentication request to CyberArk Identity; login complete username="[email protected]"
    dataupload_test.go:178:
                Error Trace:    /home/richard/projects/jetstack/jetstack-secure/pkg/internal/cyberark/dataupload/dataupload_test.go:178
                Error:          Received unexpected error:
                                while retrieving snapshot upload URL: received response with status code 400: {"error": "Invalid request format"}
                Test:           TestPostDataReadingsWithOptionsWithRealAPI
--- FAIL: TestPostDataReadingsWithOptionsWithRealAPI (1.82s)
FAIL
FAIL    github.com/jetstack/preflight/pkg/internal/cyberark/dataupload  1.834s
FAIL
POST https://tlskp-test.inventory.integration-cyberark.cloud/api/ingestions/kubernetes/snapshot-links HTTP/2.0
content-type: application/json
authorization: Bearer <REDACTED>
user-agent: Mozilla/5.0 venafi-kubernetes-agent/development
content-length: 169
accept-encoding: gzip

{"cluster_id":"bb068932-c80d-460d-88df-34bc7f3f3297","checksum_sha256":"7174d744c44b8f5f2661614089f29a560e1174f5d976048c2ae8c3e30e2f4a80","agent_version":"development"}


HTTP/2.0 400
date: Wed, 13 Aug 2025 14:18:06 GMT
content-type: application/json
content-length: 35

{"error": "Invalid request format"}

After:

$ go test -v ./pkg/internal/cyberark/dataupload/... -run Real
warning: both GOPATH and GOROOT are the same directory (/home/richard/go); see https://go.dev/wiki/InstallTroubleshooting
=== RUN   TestPostDataReadingsWithOptionsWithRealAPI
    identity.go:330: I0813 17:10:16.846642] made successful request to StartAuthentication source="Identity.doStartAuthentication" summary="NewPackage"
    identity.go:446: I0813 17:10:17.448351] successfully completed AdvanceAuthentication request to CyberArk Identity; login complete username="[email protected]"
--- PASS: TestPostDataReadingsWithOptionsWithRealAPI (4.07s)
PASS
ok      github.com/jetstack/preflight/pkg/internal/cyberark/dataupload  4.086s
POST https://tlskp-test.inventory.integration-cyberark.cloud/api/ingestions/kubernetes/snapshot-links HTTP/2.0
user-agent: Mozilla/5.0 venafi-kubernetes-agent/development
content-type: application/json
authorization: Bearer <REDACTED>
content-length: 167
accept-encoding: gzip

{"cluster_id":"bb068932-c80d-460d-88df-34bc7f3f3297","checksum_sha3":"c2ddaf1817d267c17e390ca4931a446fca5252bad9096120414bff40d87604a0","agent_version":"development"}


HTTP/2.0 200
date: Wed, 13 Aug 2025 16:10:19 GMT
content-type: application/json
content-length: 1710

{"url": "<REDACTED>"}

@wallrj-cyberark wallrj-cyberark marked this pull request as ready for review August 13, 2025 16:16
http.Error(w, "failed to unmarshal post body", http.StatusInternalServerError)
decoder.DisallowUnknownFields()
if err := decoder.Decode(&req); err != nil {
http.Error(w, `{"error": "Invalid request format"}`, http.StatusBadRequest)
return
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes the mock server respond more like the real server.

@wallrj-cyberark wallrj-cyberark changed the title [VC-43753] Use sha3 checksum in snapshot-links API request [VC-43753] CyberArk Discovery and Context: Use sha3 checksum in snapshot-links API request Aug 14, 2025
@wallrj-cyberark wallrj-cyberark requested a review from inteon August 14, 2025 08:46
@inteon
Copy link
Contributor

inteon commented Aug 14, 2025

/approve
/lgtm

@wallrj-cyberark wallrj-cyberark merged commit 68fd53f into master Aug 14, 2025
2 checks passed
@wallrj-cyberark wallrj-cyberark deleted the VC-43403-inventory-api-sha3 branch August 14, 2025 09:16
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.

3 participants