feat: add Creator username password login
CI / test (push) Failing after 15m55s

This commit is contained in:
m
2026-08-16 16:56:38 +03:00
parent 111ad75dea
commit 5fca81531a
15 changed files with 279 additions and 34 deletions
+18
View File
@@ -2,6 +2,7 @@ package creator_auth_test
import (
"encoding/json"
"git.cin.su/m/Assistant/contracts/identity"
"git.cin.su/m/Assistant/modules/identity/domain"
"strings"
"testing"
@@ -32,6 +33,23 @@ func TestCreatorSessionIsTimeBoundAndDoesNotCarryAuthority(t *testing.T) {
}
}
func TestCreatorUsernameAndPasswordMustBothMatch(t *testing.T) {
if !domain.CreatorCredentialsMatch("m", "password", identity.CreatorCredentials{Username: "m", Password: "password"}) {
t.Fatal("matching Creator credentials rejected")
}
for _, supplied := range []identity.CreatorCredentials{
{},
{Username: "m", Password: "wrong"},
{Username: "wrong", Password: "password"},
{Username: "m"},
{Password: "password"},
} {
if domain.CreatorCredentialsMatch("m", "password", supplied) {
t.Fatalf("invalid Creator credentials accepted: username=%q", supplied.Username)
}
}
}
func TestCreatorBootstrapCredentialMustMatch(t *testing.T) {
if !domain.BootstrapMatches("expected", "expected") {
t.Fatal("matching bootstrap credential rejected")
+13 -3
View File
@@ -52,11 +52,21 @@ $invalid = Invoke-WebRequest -Uri "$BaseURL/api/session/current" -Headers @{Auth
if ($invalid.StatusCode -ne 401) { throw "Invalid Creator session was not denied" }
$environment = docker --context $DockerContext inspect --format '{{range .Config.Env}}{{println .}}{{end}}' $coreContainer
$usernameEntry = $environment | Where-Object { $_ -like "CREATOR_USERNAME=*" } | Select-Object -First 1
$passwordEntry = $environment | Where-Object { $_ -like "CREATOR_PASSWORD=*" } | Select-Object -First 1
if (-not $usernameEntry -or -not $passwordEntry) { throw "Creator username/password is not configured" }
$creatorUsername = $usernameEntry.Substring("CREATOR_USERNAME=".Length)
$creatorPassword = $passwordEntry.Substring("CREATOR_PASSWORD=".Length)
$invalidCredentials = Invoke-WebRequest -Uri "$BaseURL/api/session" -Method Post -ContentType "application/json" -Body (@{username=$creatorUsername;password="invalid"} | ConvertTo-Json -Compress) -SkipHttpErrorCheck
if ($invalidCredentials.StatusCode -ne 401) { throw "Invalid Creator credentials were not denied" }
$issued = Invoke-RestMethod -Uri "$BaseURL/api/session" -Method Post -ContentType "application/json" -Body (@{username=$creatorUsername;password=$creatorPassword} | ConvertTo-Json -Compress)
if (-not $issued.Token) { throw "Creator username/password session was not issued through the gateway" }
$bootstrapEntry = $environment | Where-Object { $_ -like "CREATOR_BOOTSTRAP_TOKEN=*" } | Select-Object -First 1
if (-not $bootstrapEntry) { throw "Creator bootstrap token is not configured" }
$bootstrapToken = $bootstrapEntry.Substring("CREATOR_BOOTSTRAP_TOKEN=".Length)
$issued = Invoke-RestMethod -Uri "$BaseURL/api/session" -Method Post -Headers @{Authorization="Bearer $bootstrapToken"}
if (-not $issued.Token) { throw "Creator session was not issued through the gateway" }
$recoveryIssued = Invoke-RestMethod -Uri "$BaseURL/api/session" -Method Post -Headers @{Authorization="Bearer $bootstrapToken"}
if (-not $recoveryIssued.Token) { throw "Creator recovery session was not issued through the gateway" }
$current = Invoke-RestMethod -Uri "$BaseURL/api/session/current" -Method Get -Headers @{Authorization="Bearer $($issued.Token)"}
if ($current.ActorID -ne "domovoy-creator-actor") { throw "Creator identity was not preserved through the gateway" }
@@ -96,4 +106,4 @@ if ($staleAction.StatusCode -ne 409) { throw "Stale Creator action was not rejec
$arbitraryAction = Invoke-WebRequest -Uri "$BaseURL/api/actions/arbitrary" -Method Post -ContentType "application/json" -Headers @{Authorization="Bearer $($issued.Token)"} -Body '{}' -SkipHttpErrorCheck
if ($arbitraryAction.StatusCode -ne 404) { throw "Arbitrary action route was exposed" }
Write-Output "DEV-000032 Creator satisfaction console gateway: PASS"
Write-Output "DEV-000033 Creator username/password and console gateway: PASS"