Просмотр исходного кода

fix: address code review comments

- Fix unclosed parenthesis in AGENTS.md Expected Flow section
- Strengthen AGENTS.md Expected Flow to require explicit confirmation
  before providing commit command
- Add TestRequestParametersApplied to assert sessionDuration and
  externalID are actually forwarded to stscreds.AssumeRoleOptions

Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
Gustavo Carvalho 2 недель назад
Родитель
Сommit
9c579a800e
2 измененных файлов с 43 добавлено и 4 удалено
  1. 4 4
      AGENTS.md
  2. 39 0
      generators/v1/stsassumerole/stsassumerole_test.go

+ 4 - 4
AGENTS.md

@@ -224,11 +224,11 @@ pattern, but expect to be the first.
 
 ## Expected Flow
 - Do your best to implement all the changes needed as provided by the user
-- After finishing your implementations; Show the user your changes so they can review and COMPREHEND THEM
-- Confirm the user understood the implementation. If they confirmed they understood the implementation, and any gotchas you might be aware of,
-only then, wait for the user to commit the changes. ALWAYS ask them to sign-off their commits (`git commit -s`). It is a required step for our CLA.
+- After finishing your implementations; Show the user your changes so they can review and COMPREHEND THEM. Explain what each change does and why — do NOT just list files.
+- STOP and explicitly ask "Do you have any questions before I give you the commit command?" Wait for the user to confirm they understood before proceeding.
+- Only after the user confirms understanding: provide the commit command. ALWAYS include `-s` (sign-off) for CLA compliance.
 - After that is done, add the needed git notes to that hash.
-- Ask the user to push the changes / notes. (never do the commit or push yourself
+- Ask the user to push the changes / notes (never do the commit or push yourself).
 
 ## Restrictions
 - NEVER update v1beta1. It is deprecated and maintained for compatibility purposes only -- new features are never added there

+ 39 - 0
generators/v1/stsassumerole/stsassumerole_test.go

@@ -32,6 +32,17 @@ import (
 	clientfake "sigs.k8s.io/controller-runtime/pkg/client/fake"
 )
 
+// capturingFactory returns a credsProviderFactory that applies the received
+// optFns to a fresh AssumeRoleOptions and exposes the result for assertion.
+func capturingFactory(creds aws.Credentials, captured *stscreds.AssumeRoleOptions) credsProviderFactory {
+	return func(_ *aws.Config, _ string, optFns ...func(*stscreds.AssumeRoleOptions)) aws.CredentialsProvider {
+		for _, fn := range optFns {
+			fn(captured)
+		}
+		return &fakeCredsProvider{creds: creds}
+	}
+}
+
 type fakeCredsProvider struct {
 	creds aws.Credentials
 	err   error
@@ -220,3 +231,31 @@ spec:
 		})
 	}
 }
+
+func TestRequestParametersApplied(t *testing.T) {
+	var captured stscreds.AssumeRoleOptions
+	g := &Generator{}
+	_, _, err := g.generate(
+		context.Background(),
+		&apiextensions.JSON{Raw: []byte(`apiVersion: generators.external-secrets.io/v1alpha1
+kind: STSAssumeRoleToken
+spec:
+  region: us-east-1
+  role: arn:aws:iam::123456789012:role/my-role
+  requestParameters:
+    sessionDuration: 7200
+    externalID: my-external-id`)},
+		clientfake.NewClientBuilder().Build(),
+		"testns",
+		capturingFactory(aws.Credentials{AccessKeyID: "K", SecretAccessKey: "S", SessionToken: "T"}, &captured),
+	)
+	if err != nil {
+		t.Fatalf("unexpected error: %v", err)
+	}
+	if want := 7200 * time.Second; captured.Duration != want {
+		t.Errorf("Duration = %v, want %v", captured.Duration, want)
+	}
+	if captured.ExternalID == nil || *captured.ExternalID != "my-external-id" {
+		t.Errorf("ExternalID = %v, want %q", captured.ExternalID, "my-external-id")
+	}
+}