diff --git a/go.mod b/go.mod index d82a0604..4ba7eed3 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/rds v1.133.0 github.com/aws/aws-sdk-go-v2/service/s3 v1.114.10 github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.51.0 - github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.50.0 + github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.49.12 github.com/aws/aws-sdk-go-v2/service/sts v1.52.0 github.com/aws/smithy-go v1.28.9 github.com/containernetworking/cni v1.3.1 @@ -62,7 +62,7 @@ require ( github.com/stripe/stripe-go/v87 v87.1.0 github.com/vishvananda/netlink v1.3.1 github.com/vishvananda/netns v0.0.5 - github.com/xraph/authsome v1.12.0 + github.com/xraph/authsome v1.12.1 github.com/xraph/bastion v1.4.2 github.com/xraph/chronicle v1.11.0 github.com/xraph/chronicle/extension v1.11.0 @@ -71,7 +71,7 @@ require ( github.com/xraph/cortex v1.10.6 github.com/xraph/cortex/extension v1.10.6 github.com/xraph/ctrlplane v1.8.1 - github.com/xraph/dispatch v1.9.5 + github.com/xraph/dispatch v1.9.7 github.com/xraph/forge v1.13.7 github.com/xraph/forge/extensions/conduit v1.13.7 github.com/xraph/go-utils v1.5.0 diff --git a/go.sum b/go.sum index cea42549..0a65462e 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/aws/aws-sdk-go-v2/service/s3 v1.114.10 h1:WBJb2VxRzzKnuN94YWqZPiu5a5z github.com/aws/aws-sdk-go-v2/service/s3 v1.114.10/go.mod h1:8NhAIBVYkVHq0hIbbzujdoou0VkKwMdG+De9e5oX6qI= github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.51.0 h1:caWOS7HN0IKMRSuxxcScg39MxIg4/DgFQbW6xNjQN1I= github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.51.0/go.mod h1:pvkKaFkbMw9ehRD+fraRB1pdNyIFMeMOOo5Y4+NWB58= -github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.50.0 h1:2Id9n1VdQKsElfGN0eiA8fZZc/3J5OGPQSV3cd9J3fo= -github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.50.0/go.mod h1:Azf1g/OnnCwTXh8LxNw6ejxa0c2PNnnuRP+6Fi7/G+g= +github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.49.12 h1:dhlj1J9cS+gpPXLXCLhOfVOzoTSnr+EWmPoBMBqeRv8= +github.com/aws/aws-sdk-go-v2/service/servicediscovery v1.49.12/go.mod h1:Azf1g/OnnCwTXh8LxNw6ejxa0c2PNnnuRP+6Fi7/G+g= github.com/aws/aws-sdk-go-v2/service/signin v1.13.1 h1:ssrDA6AKfXEc3h0Pf4EI4vQ8sN5Zd136SrU9Tjr0XPc= github.com/aws/aws-sdk-go-v2/service/signin v1.13.1/go.mod h1:LdwHjKqPE9VCC7sTlWcOAizZx3ZJYjmfwC/EW2tIIAE= github.com/aws/aws-sdk-go-v2/service/sso v1.39.5 h1:ANAoa+qt3/9kXnvQVgUyxcTzhzZf4DqaBS+M2DQrELU= @@ -782,8 +782,8 @@ github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6 github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= -github.com/xraph/authsome v1.12.0 h1:6S2nGikX4dDzAUAaD4dEikarlExA3euPwMZLNHNDFis= -github.com/xraph/authsome v1.12.0/go.mod h1:vQpwXAFZj8Tt4XY8oF+f1wsvh+IOsU34rFQO0X4t8no= +github.com/xraph/authsome v1.12.1 h1:yWxi7xlSiSgh52nWkYBn6dKBiKY9DlhHX9CxXOHwCYs= +github.com/xraph/authsome v1.12.1/go.mod h1:t/2Id0S+RKAH7FMGz1XiVhRo8KypnD+8aZoXDPQXfNU= github.com/xraph/bastion v1.4.2 h1:kHXVoNUVazHIUAZq1bHcmi2EU8TPTFyX0l/ukzZHtro= github.com/xraph/bastion v1.4.2/go.mod h1:862Zqo8bol14XVglystGodqNBo72qAXIux0giixBYtw= github.com/xraph/chronicle v1.11.0 h1:+aRFsdO089LfVym2qyct+0GIF/G+WnDVFG7NTlw6o8M= @@ -806,8 +806,8 @@ github.com/xraph/cortex/sentinel v1.10.6 h1:FtSXHghMEDEXAJYf4LIi83SjPWVA8CZ9hetQ github.com/xraph/cortex/sentinel v1.10.6/go.mod h1:Q1ZzZWJ6dMwS227iXJwHhRYV9cVL7FVf4TF3cv8xWB8= github.com/xraph/ctrlplane v1.8.1 h1:RP/XoqouePA65yWsQQ7XYf2lrA7d2bVGNoGjOOIH5bM= github.com/xraph/ctrlplane v1.8.1/go.mod h1:2g10bPmnT6jlqr/dg8sqdUg8ALovQSIDze6XLMGdvow= -github.com/xraph/dispatch v1.9.5 h1:yl+Ib+ROIl6N83Y5CFWO5OLi0jvae+uTIyBieyMokik= -github.com/xraph/dispatch v1.9.5/go.mod h1:V4slR2pJiMBgVJND2DJp7Wr7ty3cLlh7EiHtdmbwYY8= +github.com/xraph/dispatch v1.9.7 h1:JSvIRn9AXpmIJl3Pt/3DHPainIQ2uDUaf2lv6ED1UJM= +github.com/xraph/dispatch v1.9.7/go.mod h1:uIbsPkpVeqan1GPJxJtowOXd7Dfo8h4VSqk5aS2Suxk= github.com/xraph/farp v1.3.1 h1:Dlcpo+gPqfx5SKFd67shPD9pl9aZqMO4txyAPFV59Y0= github.com/xraph/farp v1.3.1/go.mod h1:Nlli8WUsxvQL5wXiJqcAn6OsUHBzKJxrl9JLJ9J6Wqo= github.com/xraph/farp/discovery v1.3.1 h1:mwwBC++ftbGDlMds6IGA/kof4dAprfV2WjdMZJf3fi4= diff --git a/tests/integration/agent_off_test.go b/tests/integration/agent_off_test.go index d72eec37..b8ee7782 100644 --- a/tests/integration/agent_off_test.go +++ b/tests/integration/agent_off_test.go @@ -344,6 +344,7 @@ func joinAs(t *testing.T, a *agentOrg, email, role string) *client { _, token, _ := strings.Cut(created.AcceptPath, "token=") c := &client{t: t, base: a.r.srv.URL, key: a.cfg.Identity.PublishableKey} account(t, c, email) + verifyEmail(t, a.cfg.Database.URL, email) if code := c.do(http.MethodPost, "/authsome/v1/orgs/invitations/accept", map[string]string{"token": token}, nil); code != http.StatusOK && code != http.StatusCreated { t.Fatalf("accept: %d", code) } diff --git a/tests/integration/apikeys_test.go b/tests/integration/apikeys_test.go index 58dfb035..b08b74e0 100644 --- a/tests/integration/apikeys_test.go +++ b/tests/integration/apikeys_test.go @@ -124,6 +124,7 @@ func TestAPIKeys_actAsTheirMakerUntilRevoked(t *testing.T) { t.Fatal(err) } grace := signUp("grace@example.com") + verifyEmail(t, cfg.Database.URL, "grace@example.com") if code := grace.do(http.MethodPost, "/authsome/v1/orgs/invitations/accept", map[string]string{"token": u.Query().Get("token")}, nil); code != http.StatusOK && code != http.StatusCreated { t.Fatalf("accept: status %d", code) } diff --git a/tests/integration/cloud_capacity_api_test.go b/tests/integration/cloud_capacity_api_test.go index de1028c0..c0f02c8a 100644 --- a/tests/integration/cloud_capacity_api_test.go +++ b/tests/integration/cloud_capacity_api_test.go @@ -33,6 +33,7 @@ type capacityAPI struct { c *client org, cloud, project string sql *pgx.Conn + dsn string store *cloudinfra.PgStore deploys *deployments.PgStore } @@ -57,7 +58,7 @@ func capacityAPISetup(t *testing.T, configure ...func(*config.Config)) *capacity if err = connections.NewPgStore(db).CreateConnection(t.Context(), &connections.Connection{ID: "capacity-do", OrgID: org, Cloud: "digitalocean", Name: "Capacity", Account: "account", Status: "ready", Generation: 1, CreatedAt: now, UpdatedAt: now}); err != nil { t.Fatal(err) } - return &capacityAPI{r: r, c: c, org: org, cloud: cloud.ID, project: project, sql: sql, store: cloudinfra.NewPgStore(db), deploys: deployments.NewPgStore(db)} + return &capacityAPI{r: r, c: c, org: org, cloud: cloud.ID, project: project, sql: sql, dsn: cfg.Database.URL, store: cloudinfra.NewPgStore(db), deploys: deployments.NewPgStore(db)} } func (a *capacityAPI) path(suffix string) string { return "/api/v1/clouds/" + a.cloud + suffix } @@ -521,6 +522,7 @@ func TestCapacityAPIWaits(t *testing.T) { } viewer.must(http.StatusCreated, http.MethodPost, "/authsome/v1/signup", map[string]string{"email": "watcher@example.test", "password": "Correct-horse-battery-9"}, &auth) viewer.token = auth.SessionToken + verifyEmail(t, a.dsn, "watcher@example.test") if code := viewer.do(http.MethodPost, "/authsome/v1/orgs/invitations/accept", map[string]string{"token": accept.Query().Get("token")}, nil); code != http.StatusOK && code != http.StatusCreated { t.Fatalf("accept: %d", code) } diff --git a/tests/integration/managed_lifecycle_api_test.go b/tests/integration/managed_lifecycle_api_test.go index 0d9fefed..5ca093d7 100644 --- a/tests/integration/managed_lifecycle_api_test.go +++ b/tests/integration/managed_lifecycle_api_test.go @@ -54,6 +54,7 @@ func TestManagedLifecyclePublicAPI(t *testing.T) { } viewer := &client{t: t, base: a.c.base, key: a.c.key} account(t, viewer, "lifecycle-viewer@example.test") + verifyEmail(t, a.dsn, "lifecycle-viewer@example.test") code := viewer.do(http.MethodPost, "/authsome/v1/orgs/invitations/accept", map[string]string{"token": accept.Query().Get("token")}, nil) if code != http.StatusOK && code != http.StatusCreated { t.Fatalf("accept: %d", code) diff --git a/tests/integration/platform_test.go b/tests/integration/platform_test.go index fbf20b29..95abc770 100644 --- a/tests/integration/platform_test.go +++ b/tests/integration/platform_test.go @@ -480,6 +480,7 @@ func TestPlatform_invitationMakesADeveloper(t *testing.T) { // Grace signs up with the invited email and accepts through authsome. grace := signUp("grace@example.com") + verifyEmail(t, cfg.Database.URL, "grace@example.com") var member struct { OrgID string `json:"org_id"` } diff --git a/tests/integration/project_team_test.go b/tests/integration/project_team_test.go index 90fd95fd..d14fb47f 100644 --- a/tests/integration/project_team_test.go +++ b/tests/integration/project_team_test.go @@ -35,6 +35,7 @@ func (w *teamsWorld) joinAs(c *client, email, role string) { if err != nil { w.t.Fatal(err) } + verifyEmail(w.t, w.dsn, email) if code := c.do(http.MethodPost, "/authsome/v1/orgs/invitations/accept", map[string]string{"token": u.Query().Get("token")}, nil); code != http.StatusOK && code != http.StatusCreated { w.t.Fatalf("%s accepts: status %d", email, code) } diff --git a/tests/integration/retirement_api_test.go b/tests/integration/retirement_api_test.go index 3d3c9875..27fac1fd 100644 --- a/tests/integration/retirement_api_test.go +++ b/tests/integration/retirement_api_test.go @@ -251,6 +251,7 @@ func TestRetirementAPIIsScopedAndVerifiesBytesBeforeRetry(t *testing.T) { } admin.must(http.StatusCreated, http.MethodPost, "/authsome/v1/signup", map[string]string{"email": "retirement-admin@example.test", "password": "Correct-horse-battery-9"}, &signed) admin.token = signed.SessionToken + verifyEmail(t, cfg.Database.URL, "retirement-admin@example.test") status := admin.do(http.MethodPost, "/authsome/v1/orgs/invitations/accept", map[string]string{"token": inviteURL.Query().Get("token")}, nil) if status != http.StatusOK && status != http.StatusCreated { t.Fatalf("admin invitation: %d", status) diff --git a/tests/integration/security_test.go b/tests/integration/security_test.go index 89d8ba16..5fb20617 100644 --- a/tests/integration/security_test.go +++ b/tests/integration/security_test.go @@ -62,6 +62,7 @@ func TestSecurity_organizationsAndRolesHoldEverywhere(t *testing.T) { t.Fatal(err) } c := signUp(email) + verifyEmail(t, cfg.Database.URL, email) if code := c.do(http.MethodPost, "/authsome/v1/orgs/invitations/accept", map[string]string{"token": u.Query().Get("token")}, nil); code != http.StatusOK && code != http.StatusCreated { t.Fatalf("accept: %d", code) } @@ -186,6 +187,7 @@ func TestSecurity_organizationsAndRolesHoldEverywhere(t *testing.T) { if err != nil { t.Fatal(err) } + verifyEmail(t, cfg.Database.URL, "grace@example.com") if code := grace.do(http.MethodPost, "/authsome/v1/orgs/invitations/accept", map[string]string{"token": iu.Query().Get("token")}, nil); code != http.StatusOK && code != http.StatusCreated { t.Fatalf("accept: %d", code) } diff --git a/tests/integration/setup_test.go b/tests/integration/setup_test.go index 092e2f17..bc68e7e6 100644 --- a/tests/integration/setup_test.go +++ b/tests/integration/setup_test.go @@ -621,8 +621,9 @@ func TestSetup_earlierOwnerIsVerifiedOnStart(t *testing.T) { } // ordinaryMember invites email to owner's organization as a viewer and -// returns a client signed in as them. They hold no platform role. -func ordinaryMember(t *testing.T, owner *setupClient, email string) *setupClient { +// returns a client signed in as them. They hold no platform role. dsn is +// the instance's database, where their address is marked verified. +func ordinaryMember(t *testing.T, owner *setupClient, dsn, email string) *setupClient { t.Helper() var created struct { AcceptPath string `json:"accept_path"` @@ -648,6 +649,7 @@ func ordinaryMember(t *testing.T, owner *setupClient, email string) *setupClient if member.cookie == nil { t.Fatalf("%s sign-in set no session cookie", email) } + verifyEmail(t, dsn, email) if status, raw, _ := member.send(http.MethodPost, "/authsome/v1/orgs/invitations/accept", map[string]string{"token": token}); status != http.StatusOK && status != http.StatusCreated { t.Fatalf("%s accept: %d %s", email, status, raw) } @@ -676,7 +678,7 @@ func TestSetup_cloudSignInOffer(t *testing.T) { t.Fatalf("anonymous public config = %+v, want neither", got) } - grace := ordinaryMember(t, owner, "grace@example.com") + grace := ordinaryMember(t, owner, cfg.Database.URL, "grace@example.com") if got := grace.publicConfig(); got.PlatformAdmin || got.CloudSignInOffer { t.Fatalf("an ordinary member's public config = %+v, want neither", got) } diff --git a/tests/integration/signup_gate_test.go b/tests/integration/signup_gate_test.go index 5ac98928..155c361b 100644 --- a/tests/integration/signup_gate_test.go +++ b/tests/integration/signup_gate_test.go @@ -98,6 +98,15 @@ func execSQL(t *testing.T, dsn, query string, args ...any) { } } +// verifyEmail marks the account holding email as having verified it, as +// using the code in the verification email would. Authsome only lets an +// invitee accept once the invited address is verified, and these tests +// sign people up with verification off. +func verifyEmail(t *testing.T, dsn, email string) { + t.Helper() + execSQL(t, dsn, `UPDATE authsome_users SET email_verified = true WHERE lower(email) = lower($1)`, email) +} + func TestSignupGate_pendingRefusesEveryone(t *testing.T) { on, off := true, false for name, waitlist := range map[string]*bool{"waitlist off": &off, "waitlist on": &on, "waitlist unset": nil} { diff --git a/tests/integration/teams_test.go b/tests/integration/teams_test.go index e218fe98..0280effb 100644 --- a/tests/integration/teams_test.go +++ b/tests/integration/teams_test.go @@ -31,6 +31,7 @@ type teamsWorld struct { r *running app forge.App sql *pgx.Conn + dsn string key string org string ada *client @@ -47,7 +48,7 @@ func newTeamsWorld(t *testing.T) *teamsWorld { cfg.Database.URL = freshDatabase(t) cfg.Orchestration.PollInterval = 100 * time.Millisecond cfg.AI.Enabled = false - w := &teamsWorld{t: t, key: cfg.Identity.PublishableKey} + w := &teamsWorld{t: t, key: cfg.Identity.PublishableKey, dsn: cfg.Database.URL} w.r = startApp(t, cfg, func(a forge.App) { w.app = a }) t.Cleanup(w.r.stop) conn, err := pgx.Connect(t.Context(), cfg.Database.URL) @@ -89,6 +90,7 @@ func (w *teamsWorld) join(c *client, email string) { if err != nil { w.t.Fatal(err) } + verifyEmail(w.t, w.dsn, email) if code := c.do(http.MethodPost, "/authsome/v1/orgs/invitations/accept", map[string]string{"token": u.Query().Get("token")}, nil); code != http.StatusOK && code != http.StatusCreated { w.t.Fatalf("%s accepts: status %d", email, code) }