-
Notifications
You must be signed in to change notification settings - Fork 174
Appending Pulumi APN 1.1 marketplace id to User Agent request header #5920
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
Open
pose
wants to merge
3
commits into
v6-security-patch
Choose a base branch
from
pose/chores/apn1.1-ported-to-v6
base: v6-security-patch
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+142
−71
Open
Changes from 1 commit
Commits
Show all changes
3 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
19 changes: 19 additions & 0 deletions
19
patches/0060-Adding-APN-1.1-marketplace-identifier-to-User-Agent-.patch
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,19 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Alberto Pose <[email protected]> | ||
| Date: Thu, 23 Oct 2025 11:11:23 +0100 | ||
| Subject: [PATCH] Adding APN 1.1 marketplace identifier to User Agent request | ||
| string. | ||
|
|
||
|
|
||
| diff --git a/internal/conns/config.go b/internal/conns/config.go | ||
| index c1d3e94c55..74be293b99 100644 | ||
| --- a/internal/conns/config.go | ||
| +++ b/internal/conns/config.go | ||
| @@ -80,6 +80,7 @@ func (c *Config) ConfigureProvider(ctx context.Context, client *AWSClient) (*AWS | ||
| Products: []awsbase.UserAgentProduct{ | ||
| {Name: "Pulumi", Version: "1.0"}, | ||
| {Name: "Pulumi-Aws", Version: c.TerraformVersion, Comment: "+https://pulumi.com"}, | ||
| + {Name: "APN", Version: "1.1", Comment: "c7qiae2l6usvzoynupds6v7hf"}, | ||
| }, | ||
| }, | ||
| AssumeRole: c.AssumeRole, |
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,91 @@ | ||
| package provider | ||
|
|
||
| import ( | ||
| "context" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "testing" | ||
|
|
||
| structpb "github.com/golang/protobuf/ptypes/struct" | ||
| pfbridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge" | ||
| pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func testProviderServer() (pulumirpc.ResourceProviderServer, error) { | ||
| info := *Provider() | ||
| ctx := context.Background() | ||
| p, err := pfbridge.MakeMuxedServer(ctx, info.Name, info, | ||
| /* | ||
| * We leave the schema blank. This will result in incorrect calls to | ||
| * GetSchema, but otherwise does not effect the provider. It reduces the | ||
| * time to test start by minutes. | ||
| */ | ||
| []byte("{}"), | ||
| )(nil) | ||
| return p, err | ||
| } | ||
|
|
||
| func TestProviderEndpoints(t *testing.T) { | ||
| stsGetCallerIdentityResponse := ` | ||
| <GetCallerIdentityResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/"> | ||
| <GetCallerIdentityResult> | ||
| <Arn>arn:aws:iam::123456789012:user/Alice</Arn> | ||
| <UserId>AIDACKCEVSQ6C2EXAMPLE</UserId> | ||
| <Account>123456789012</Account> | ||
| </GetCallerIdentityResult> | ||
| <ResponseMetadata> | ||
| <RequestId>01234567-89ab-cdef-0123-456789abcdef</RequestId> | ||
| </ResponseMetadata> | ||
| </GetCallerIdentityResponse>` | ||
|
|
||
| t.Run("requests to AWS use the APN/1.1 marketplace identifier in the User-Agent request header", func(t *testing.T) { | ||
| requestCount := 0 | ||
| server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| assert.Contains(t, r.Header.Get("User-Agent"), "APN/1.1 (c7qiae2l6usvzoynupds6v7hf)") | ||
| switch requestCount { | ||
| case 0: | ||
| w.Write([]byte(stsGetCallerIdentityResponse)) | ||
| case 1: | ||
| w.Write([]byte("{}")) | ||
| default: | ||
| t.Fatalf("Unexpected request count: %d", requestCount) | ||
| } | ||
| requestCount++ | ||
| })) | ||
| t.Cleanup(server.Close) | ||
|
|
||
| // Using environment variables since configuring passing variables to | ||
| // provider.Configure is too late on the lifecycle of the provider. These | ||
| // values are fetched when the provider is initialized. | ||
| t.Setenv("AWS_ENDPOINT_URL", server.URL) | ||
| t.Setenv("AWS_SKIP_METADATA_API_CHECK", "true") | ||
| t.Setenv("AWS_SKIP_CREDENTIALS_VALIDATION", "true") | ||
| t.Setenv("AWS_ACCESS_KEY_ID", "test") | ||
| t.Setenv("AWS_SECRET_ACCESS_KEY", "test") | ||
| t.Setenv("AWS_SESSION_TOKEN", "test") | ||
| t.Setenv("AWS_REGION", "us-west-2") | ||
| t.Setenv("AWS_PROFILE", "") | ||
|
|
||
| provider, err := testProviderServer() | ||
| require.NoError(t, err) | ||
| ctx := context.Background() | ||
| _, err = provider.Configure(ctx, &pulumirpc.ConfigureRequest{}) | ||
| require.NoError(t, err) | ||
| _, err = provider.Invoke(ctx, &pulumirpc.InvokeRequest{ | ||
| Tok: "aws:s3/getObjects:getObjects", | ||
| Args: &structpb.Struct{ | ||
| Fields: map[string]*structpb.Value{ | ||
| "bucket": { | ||
| Kind: &structpb.Value_StringValue{ | ||
| StringValue: "test-bucket", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
| require.NoError(t, err) | ||
| assert.Equal(t, 2, requestCount) | ||
| }) | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be changing, but it looks like it's just the tests so maybe it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the issue is that somehow the diff moved the functions around. Not sure why the diff generation is not stable. I didn't modify any of these files as part of my change.