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
180 changes: 99 additions & 81 deletions apps/backend/CLAUDE.md

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions apps/backend/cmd/api/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func TestTheExampleConfigStillReachesTheStructs(t *testing.T) {
assert.Equal(t, 5*time.Minute, config.Planet.Ledger.SweepInterval)
assert.Equal(t, time.Second, config.Planet.LedgerStorage.FlushInterval)

assert.False(t, config.Planet.AntiBot.ShadowBan.Enforce, "the example must ship observing only")
assert.Equal(t, []time.Duration{24 * time.Hour, 7 * 24 * time.Hour, 3 * 365 * 24 * time.Hour}, config.Planet.AntiBot.ShadowBan.BanDurations)
assert.False(t, config.Planet.AntiBot.Bans.Enforce, "the example must ship observing only")
assert.Equal(t, []time.Duration{24 * time.Hour, 7 * 24 * time.Hour, 3 * 365 * 24 * time.Hour}, config.Planet.AntiBot.Bans.BanDurations)
assert.Equal(t, "antibot", config.Planet.AntiBot.Database.Schema)
assert.Equal(t, 5*time.Minute, config.Planet.AntiBot.ShadowBan.ReflagInterval)
assert.Equal(t, 5*time.Minute, config.Planet.AntiBot.Bans.ReflagInterval)

assert.Equal(t, 2, config.Planet.AntiBot.Jury.MinSuspects)
assert.Equal(t, 10*time.Minute, config.Planet.AntiBot.Jury.SuspicionWindow)
Expand Down Expand Up @@ -370,7 +370,9 @@ func TestTheExampleConfigReachesTheAttachments(t *testing.T) {
assert.Equal(t, "clickplanet-support", attachments.Bucket.Name)
}

func TestTheProductionConfigTakesFilesInItsBucketAndNeedsItsSecret(t *testing.T) {
func productionConfig(t *testing.T) Config {
t.Helper()

const production = "../../../../deploy/vps/backend.yaml"
file, err := os.ReadFile(production)
require.NoError(t, err)
Expand All @@ -384,6 +386,19 @@ func TestTheProductionConfigTakesFilesInItsBucketAndNeedsItsSecret(t *testing.T)

var config Config
require.NoError(t, cpconfigs.Load(&config, cpconfigs.FromFile(production)))
return config
}

func TestTheProductionConfigEnforcesBans(t *testing.T) {
config := productionConfig(t)

assert.True(t, config.Planet.AntiBot.Enabled)
assert.True(t, config.Planet.AntiBot.Bans.Enforce, "a key the config does not read leaves bans off without a word")
assert.Equal(t, []time.Duration{24 * time.Hour, 7 * 24 * time.Hour, 3 * 365 * 24 * time.Hour}, config.Planet.AntiBot.Bans.BanDurations)
}

func TestTheProductionConfigTakesFilesInItsBucketAndNeedsItsSecret(t *testing.T) {
config := productionConfig(t)

attachments := config.Support.Attachments
assert.True(t, attachments.Enabled)
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/cmd/api/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ antiBot:
pool:
maxOpenConns: 2

shadowBan:
bans:
enforce: false
banDurations: [24h, 168h, 26280h]
reflagInterval: 5m
Expand Down
Loading
Loading