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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
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.1
github.com/xraph/authsome v1.12.2
github.com/xraph/bastion v1.4.2
github.com/xraph/chronicle v1.11.0
github.com/xraph/chronicle/extension v1.11.0
Expand All @@ -82,7 +82,7 @@ require (
github.com/xraph/herald v1.10.3
github.com/xraph/herald/drivers/apns v1.10.3
github.com/xraph/keysmith v1.9.1
github.com/xraph/ledger v1.9.2
github.com/xraph/ledger v1.9.3
github.com/xraph/nexus v1.9.3
github.com/xraph/nexus/providers/anthropic v1.9.1
github.com/xraph/nexus/providers/openai v1.9.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
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.1 h1:yWxi7xlSiSgh52nWkYBn6dKBiKY9DlhHX9CxXOHwCYs=
github.com/xraph/authsome v1.12.1/go.mod h1:t/2Id0S+RKAH7FMGz1XiVhRo8KypnD+8aZoXDPQXfNU=
github.com/xraph/authsome v1.12.2 h1:d3lmVO80e0ZJknuNGysK2rw9rVANkBihNQddj9uBZaA=
github.com/xraph/authsome v1.12.2/go.mod h1:bwi67iJdJ2hPrBC4yV5qtgo+qTl20JfPMzLTr3baX20=
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 Down Expand Up @@ -842,8 +842,8 @@ github.com/xraph/herald/drivers/apns v1.10.3 h1:B24dlJj+UrZ1bzpndL7IJHUvDhXXprPo
github.com/xraph/herald/drivers/apns v1.10.3/go.mod h1:MUbgvOsvjcda3SGf4LjQLtLQrsVflAbZAXKnpiBBU78=
github.com/xraph/keysmith v1.9.1 h1:ZtZ+j1ZbxHKMJzkRnZWwo0hJLsB86Ro5oe7sWCoMKlQ=
github.com/xraph/keysmith v1.9.1/go.mod h1:WPSJLvoXi8g8LvV2+Tg4JOafGeb+/PlC8ZaW8XYIYss=
github.com/xraph/ledger v1.9.2 h1:h+9wWFkf1rGmdWknqTlaVu7eBTIZw0qpuWzQ+vQuPV0=
github.com/xraph/ledger v1.9.2/go.mod h1:k769SQtmWXI9I4DKbja26oZdH/sW29qE/8Y5iNstsdg=
github.com/xraph/ledger v1.9.3 h1:oz4tlIdDxThus7nX28vpQW//DPzM1yDUStkJV90jQrQ=
github.com/xraph/ledger v1.9.3/go.mod h1:qJvX411LrVwLXwkkVh1UAjUxRpj44c99XvCRjImKSFA=
github.com/xraph/nexus v1.9.3 h1:swjUBnkGFYs6f0sifyW7a7CmHetwjmslUKGsH19CFhQ=
github.com/xraph/nexus v1.9.3/go.mod h1:0hU8ddSNwAw1bh7HlAe9v4ftR0VR0FlYZqpRjKAuhT0=
github.com/xraph/nexus/providers/anthropic v1.9.1 h1:xoIc53B8DmKun+MLPWTFruMGotpSPoCWeOvBx8uk87g=
Expand Down
1 change: 1 addition & 0 deletions tests/integration/nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ func TestNodes_listCancelAndLimitJoinTokens(t *testing.T) {
Inventory: nodeproto.Inventory{OS: "linux", Arch: "amd64"}, NodeVersion: buildinfo.Version, ProtocolVersion: nodeproto.Version,
}, nil)
}
inOneRateWindow(t) // every join from here on counts against one window
if got := join(scoped.Token); got != http.StatusUnauthorized {
t.Fatalf("join with a cancelled token: %d", got)
}
Expand Down
1 change: 1 addition & 0 deletions tests/integration/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ func TestSetup_validation(t *testing.T) {
long := strings.Repeat("x", 65)
// Five, the most one address may send a minute. The unit tests cover
// the other refusals.
inOneRateWindow(t)
for name, form := range map[string]map[string]string{
"no name": {"email": "ada@example.com", "password": "Correct-horse-battery-9", "organization_name": "Acme"},
"bad email": {"name": "Ada", "email": "not an email", "password": "Correct-horse-battery-9", "organization_name": "Acme"},
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/signup_gate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,20 @@ func TestSignupGate_burstCantWedgeThePool(t *testing.T) {
}
}

// inOneRateWindow waits, when it has to, so that what follows starts with
// at least half of a rate-limit window left. The limiter Loomplane gives
// authsome counts in fixed windows aligned to the minute, so a run of
// requests that crosses a boundary starts counting again from zero. Under
// -race on CI a handful of sign-ups can take long enough for that to happen.
func inOneRateWindow(t *testing.T) {
t.Helper()
const window = time.Minute // authsome's default, which these tests keep
now := time.Now()
if left := now.Truncate(window).Add(window).Sub(now); left < window/2 {
time.Sleep(left + 100*time.Millisecond)
}
}

// authsome takes three sign-ups a minute from one address. The gate runs
// in front of that route, so it counts against the same budget first: a
// flood from one address gets 429s before the gate looks anything up, so
Expand All @@ -405,6 +419,7 @@ func TestSignupGate_floodIsRateLimited(t *testing.T) {
}

flood := &setupClient{t: t, base: c.base, key: c.key, from: "203.0.113.7"}
inOneRateWindow(t)
codes := make([]int, 0, 6)
for i := range 6 {
status, _, _ := flood.send(http.MethodPost, "/authsome/v1/signup",
Expand All @@ -426,6 +441,7 @@ func TestSignupGate_floodIsRateLimited(t *testing.T) {
// again on authsome's route: three invited people can sign up from one
// address, and only a fourth sign-up is turned away.
office := &setupClient{t: t, base: c.base, key: c.key, from: "192.0.2.10"}
inOneRateWindow(t)
for i := range 3 {
email := fmt.Sprintf("colleague%d@example.com", i)
if status, raw, _ := c.send(http.MethodPost, "/api/v1/invitations", map[string]string{"email": email}); status != http.StatusCreated {
Expand Down
Loading