Files
Denozordec 34ecc5c235
CI / changes (push) Successful in 6s
CI / openapi (push) Successful in 1m2s
CI / go (push) Successful in 27s
CI / docker-web (push) Successful in 1m27s
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 16s
CI / docker-go (push) Successful in 8m5s
feat: enhance DoH profile management and resolver policy in modules
- Added `DohResolverPolicy` schema to OpenAPI documentation, defining policies for domain resolution.
- Updated module handling to support multiple DoH profiles via `doh_profile_ids` and introduced `doh_resolver_policy` in the API.
- Refactored related functions to accommodate the new DoH profile structure, ensuring backward compatibility with existing `doh_profile_id`.
- Enhanced UI components to allow selection and management of DoH profiles and policies in the web interface.
- Updated database interactions to handle new fields and ensure proper data normalization.
2026-05-19 14:57:50 +07:00

33 lines
1017 B
Go

package store
import "testing"
func TestNormalizeDohProfileIDList(t *testing.T) {
got := NormalizeDohProfileIDList([]string{" a ", "b", "a", "", "b"})
if len(got) != 2 || got[0] != "a" || got[1] != "b" {
t.Fatalf("unexpected: %v", got)
}
}
func TestApplyModuleDohPatch(t *testing.T) {
mod := &Module{DohProfileIDs: []string{"one"}, DohResolverPolicy: DohPolicyPrimaryOnly}
ids := []string{"ru", "eu"}
policy := DohPolicyUnion
ApplyModuleDohPatch(mod, &ModulePatch{DohProfileIDs: &ids, DohResolverPolicy: &policy})
if len(mod.DohProfileIDs) != 2 || mod.DohResolverPolicy != DohPolicyUnion {
t.Fatalf("unexpected module doh fields: %+v", mod)
}
if mod.DohProfileID == nil || *mod.DohProfileID != "ru" {
t.Fatalf("legacy id not synced: %+v", mod.DohProfileID)
}
}
func TestEffectiveDohProfileIDs_LegacyField(t *testing.T) {
id := "legacy-id"
mod := &Module{DohProfileID: &id}
got := mod.EffectiveDohProfileIDs()
if len(got) != 1 || got[0] != "legacy-id" {
t.Fatalf("unexpected: %v", got)
}
}