chore: checkpoint assessment and inbox integration
This commit is contained in:
1 parent
88a31ba0d5
commit
5c52fd8b91
31 files changed
+4608
-181
No files matched your search
@@ -0,0 +1,12 @@
|
||||
package config
|
||||
|
||||
// loadAssessment reads narrowly scoped assessment feature gates. All gates
|
||||
// default off so configuration cannot silently grant synthetic provenance.
|
||||
func (config *Config) loadAssessment(lookup LookupEnv) error {
|
||||
enabled, err := boolOrDefault(lookup, "ASSESSMENT_DEMO_CATEGORIES_ENABLED", false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
config.AssessmentDemoCategoriesEnabled = enabled
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoadFromEnvAssessmentDemoCategoriesDefaultsOff(t *testing.T) {
|
||||
settings, err := LoadFromEnv(testEnvironment(nil))
|
||||
if err != nil {
|
||||
t.Fatalf("LoadFromEnv() error = %v", err)
|
||||
}
|
||||
if settings.AssessmentDemoCategoriesEnabled {
|
||||
t.Fatal("AssessmentDemoCategoriesEnabled = true, want default false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadFromEnvAssessmentDemoCategoriesReadsExplicitValue(t *testing.T) {
|
||||
settings, err := LoadFromEnv(testEnvironment(map[string]string{
|
||||
"ASSESSMENT_DEMO_CATEGORIES_ENABLED": " TRUE ",
|
||||
}))
|
||||
if err != nil {
|
||||
t.Fatalf("LoadFromEnv() error = %v", err)
|
||||
}
|
||||
if !settings.AssessmentDemoCategoriesEnabled {
|
||||
t.Fatal("AssessmentDemoCategoriesEnabled = false, want explicit true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadFromEnvAssessmentDemoCategoriesRejectsAmbiguousValue(t *testing.T) {
|
||||
_, err := LoadFromEnv(testEnvironment(map[string]string{
|
||||
"ASSESSMENT_DEMO_CATEGORIES_ENABLED": "yes",
|
||||
}))
|
||||
if err == nil || !strings.HasPrefix(err.Error(), "config.boolOrDefault - ASSESSMENT_DEMO_CATEGORIES_ENABLED") {
|
||||
t.Fatalf("LoadFromEnv() error = %v, want a strict boolean setting error", err)
|
||||
}
|
||||
}
|
||||
@@ -143,6 +143,9 @@ type Config struct {
|
||||
// IdentitySessionAbsoluteLifetime is the maximum lifetime of a session,
|
||||
// even when it remains active.
|
||||
IdentitySessionAbsoluteLifetime time.Duration
|
||||
// AssessmentDemoCategoriesEnabled explicitly enables synthetic demo category
|
||||
// assignment. Reviewed source provenance is required separately.
|
||||
AssessmentDemoCategoriesEnabled bool
|
||||
|
||||
// TrustedProxyCIDRs are the reverse proxies in front of the API. The
|
||||
// client address is taken from X-Forwarded-For only through them (see
|
||||
@@ -197,10 +200,7 @@ func LoadFromEnv(lookup LookupEnv) (Config, error) {
|
||||
if err := config.loadPasswordHash(lookup); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
if err := config.loadIdentity(lookup); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
if err := config.loadTrustedProxies(lookup); err != nil {
|
||||
if err := config.loadIdentityAndProxySettings(lookup); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
@@ -231,6 +231,16 @@ func LoadFromEnv(lookup LookupEnv) (Config, error) {
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func (config *Config) loadIdentityAndProxySettings(lookup LookupEnv) error {
|
||||
if err := config.loadIdentity(lookup); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := config.loadAssessment(lookup); err != nil {
|
||||
return err
|
||||
}
|
||||
return config.loadTrustedProxies(lookup)
|
||||
}
|
||||
|
||||
func (config Config) Validate() error {
|
||||
if err := config.ValidateSeaweedFS(); err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user