Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand Down
1 change: 1 addition & 0 deletions tests/integration/agent_off_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions tests/integration/apikeys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/cloud_capacity_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type capacityAPI struct {
c *client
org, cloud, project string
sql *pgx.Conn
dsn string
store *cloudinfra.PgStore
deploys *deployments.PgStore
}
Expand All @@ -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 }
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions tests/integration/managed_lifecycle_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tests/integration/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
1 change: 1 addition & 0 deletions tests/integration/project_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions tests/integration/retirement_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 5 additions & 3 deletions tests/integration/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/signup_gate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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} {
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/teams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type teamsWorld struct {
r *running
app forge.App
sql *pgx.Conn
dsn string
key string
org string
ada *client
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down
Loading