Skip to content

Add payload to auth request#49

Merged
carole-lavillonniere merged 2 commits intomainfrom
carole/drg-548
Feb 25, 2026
Merged

Add payload to auth request#49
carole-lavillonniere merged 2 commits intomainfrom
carole/drg-548

Conversation

@carole-lavillonniere
Copy link
Copy Markdown
Collaborator

@carole-lavillonniere carole-lavillonniere commented Feb 25, 2026

Add {"actor": "lstk", "version": "0.1.0"} as payload of POST /v1/auth/request.
Related PR https://github.com/localstack/localstack-platform/pull/1695
closes DRG-548
cc @Pive01

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

Adds a JSON body with actor "lstk" and version to CreateAuthRequest, expands PlatformAPI with three new license/token methods and related exported types, and updates the integration test mock to decode and validate the new auth request payload.

Changes

Cohort / File(s) Summary
Client & API surface
internal/api/client.go
CreateAuthRequest now marshals and sends JSON payload {actor:"lstk", version:<version.Version()>} with Content-Type header; adds const actor = "lstk" and imports internal/version; extends PlatformAPI with ExchangeAuthRequest, GetLicenseToken, GetLicense and introduces exported types LicenseRequest, ProductInfo, CredentialsInfo, MachineInfo.
Integration test handler
test/integration/login_test.go
Mock POST /v1/auth/request handler now decodes incoming JSON and asserts actor == "lstk" and non-empty version; adjusts error handling to avoid shadowing.

Sequence Diagram(s)

(omitted — changes are limited to client payload, API surface additions, and test validation)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • silv-io
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add payload to auth request' directly describes the main change: adding a JSON payload to the auth request endpoint.
Description check ✅ Passed The PR description clearly relates to the changeset by specifying the exact JSON payload being added to the auth request endpoint.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch carole/drg-548

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/api/client.go (1)

77-80: Consider extracting "cli-v2" as a named constant.

The actor string is hardcoded here and again in the test assertion (assert.Equal(t, "cli-v2", ...)). A single constant eliminates the duplication and makes future actor renaming a one-line change.

♻️ Proposed refactor

In internal/api/client.go (or a shared constants file):

+const authRequestActor = "cli-v2"

 func (c *PlatformClient) CreateAuthRequest(ctx context.Context) (*AuthRequest, error) {
     payload := map[string]string{
-        "actor":   "cli-v2",
+        "actor":   authRequestActor,
         "version": version.Version(),
     }

In test/integration/login_test.go (reference the same constant or keep a local mirror if the test package cannot import internal/api):

-    assert.Equal(t, "cli-v2", payload["actor"], "actor should be cli-v2")
+    assert.Equal(t, "cli-v2", payload["actor"], "actor should be cli-v2") // keep in sync with authRequestActor in internal/api
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/api/client.go` around lines 77 - 80, Extract the hardcoded actor
string "cli-v2" into a single named constant (e.g., const Actor = "cli-v2") in
the same package that defines the payload so the payload map uses Actor instead
of the literal; then update the test assertion that expects "cli-v2" to
reference that constant (or create a test-local mirror if the test package
cannot import the constant) so the actor value is defined in one place and
duplicated literals are removed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/api/client.go`:
- Around line 77-80: Extract the hardcoded actor string "cli-v2" into a single
named constant (e.g., const Actor = "cli-v2") in the same package that defines
the payload so the payload map uses Actor instead of the literal; then update
the test assertion that expects "cli-v2" to reference that constant (or create a
test-local mirror if the test package cannot import the constant) so the actor
value is defined in one place and duplicated literals are removed.

ℹ️ Review info

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c1f8ad and 379c5b8.

📒 Files selected for processing (2)
  • internal/api/client.go
  • test/integration/login_test.go

Copy link
Copy Markdown
Member

@silv-io silv-io left a comment

Choose a reason for hiding this comment

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

LGTM!

Just some clarifying questions

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/integration/login_test.go (1)

31-31: Remove the redundant inline comment.

Line 31 (// Validate request payload) restates what the next lines already make obvious.

As per coding guidelines, "Don't add comments for self-explanatory code. Only comment when the "why" isn't obvious from the code itself."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/integration/login_test.go` at line 31, Remove the redundant inline
comment "// Validate request payload" from the test file; locate that exact
comment string in login_test.go (near the login test setup) and delete it so the
code reads without the self-explanatory comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/integration/login_test.go`:
- Line 31: Remove the redundant inline comment "// Validate request payload"
from the test file; locate that exact comment string in login_test.go (near the
login test setup) and delete it so the code reads without the self-explanatory
comment.

ℹ️ Review info

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 379c5b8 and f9099cd.

📒 Files selected for processing (2)
  • internal/api/client.go
  • test/integration/login_test.go

@carole-lavillonniere carole-lavillonniere merged commit 3200ba4 into main Feb 25, 2026
8 checks passed
@carole-lavillonniere carole-lavillonniere deleted the carole/drg-548 branch February 25, 2026 14:35
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