-
Notifications
You must be signed in to change notification settings - Fork 39
build: re-bump speakeasy-core/client-sdk-go with registry auth fixed + regression coverage #2121
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
+90
−10
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package sdk | ||
|
|
||
| import ( | ||
| "context" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "sync" | ||
| "testing" | ||
|
|
||
| speakeasy "github.com/speakeasy-api/speakeasy-client-sdk-go/v3" | ||
| "github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations" | ||
| "github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // Guards against the SDK silently dropping auth on registry operations. | ||
| // client-sdk-go v3.27.0 was generated from a spec that marked all Artifacts | ||
| // and Subscriptions operations `security: []`, so these calls went out with | ||
| // no x-api-key header and the platform returned 403s (CLI v1.795.2, reverted | ||
| // in #2120). Nothing fails at compile time when that happens — the only | ||
| // observable difference is the missing header, which this test pins down for | ||
| // the operations the CLI actually calls. | ||
| func TestInitSDKWithKey_SendsAPIKeyOnRegistryOperations(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| var mu sync.Mutex | ||
| apiKeyByPath := map[string]string{} | ||
| server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| mu.Lock() | ||
| apiKeyByPath[r.URL.Path] = r.Header.Get("x-api-key") | ||
| mu.Unlock() | ||
| w.Header().Set("Content-Type", "application/json") | ||
| w.WriteHeader(http.StatusOK) | ||
| _, _ = w.Write([]byte(`{}`)) | ||
| })) | ||
| defer server.Close() | ||
|
|
||
| s, err := InitSDKWithKey("test-api-key", speakeasy.WithServerURL(server.URL)) | ||
| require.NoError(t, err) | ||
|
|
||
| ctx := context.Background() | ||
|
|
||
| // registry/tagging.go (speakeasy tag promote/apply, ci tag) | ||
| _, _ = s.Artifacts.PostTags(ctx, operations.PostTagsRequest{ | ||
| NamespaceName: "test-namespace", | ||
| AddTags: &shared.AddTags{ | ||
| RevisionDigest: "sha256:0000000000000000000000000000000000000000000000000000000000000000", | ||
| Tags: []string{"main"}, | ||
| }, | ||
| }) | ||
|
|
||
| // internal/remote/sources.go hasMainRevision | ||
| _, _ = s.Artifacts.GetRevisions(ctx, operations.GetRevisionsRequest{ | ||
| NamespaceName: "test-namespace", | ||
| }) | ||
|
|
||
| // The response bodies above are not representative, so the calls may | ||
| // return unmarshalling errors — all this test cares about is that the | ||
| // requests carried the API key. | ||
| mu.Lock() | ||
| defer mu.Unlock() | ||
| require.Len(t, apiKeyByPath, 2, "expected both operations to reach the server") | ||
| for path, apiKey := range apiKeyByPath { | ||
| require.Equalf(t, "test-api-key", apiKey, "request to %s was sent without the x-api-key header: the SDK dropped auth for this operation", path) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.