platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
60
selective-vpn-api/app/transport_policy_owner_lock_test.go
Normal file
60
selective-vpn-api/app/transport_policy_owner_lock_test.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package app
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDetectTransportOwnerLockConflicts(t *testing.T) {
|
||||
current := []TransportPolicyIntent{
|
||||
{SelectorType: "domain", SelectorValue: "example.com", ClientID: "c1"},
|
||||
}
|
||||
next := []TransportPolicyIntent{
|
||||
{SelectorType: "domain", SelectorValue: "example.com", ClientID: "c2"},
|
||||
}
|
||||
clients := []TransportClient{
|
||||
{ID: "c1", Status: TransportClientUp},
|
||||
{ID: "c2", Status: TransportClientUp},
|
||||
}
|
||||
|
||||
conflicts := detectTransportOwnerLockConflicts(current, next, clients)
|
||||
if len(conflicts) != 1 {
|
||||
t.Fatalf("expected 1 conflict, got %d (%#v)", len(conflicts), conflicts)
|
||||
}
|
||||
if conflicts[0].Type != "owner_lock" {
|
||||
t.Fatalf("unexpected conflict type: %q", conflicts[0].Type)
|
||||
}
|
||||
if conflicts[0].Severity != "block" {
|
||||
t.Fatalf("unexpected conflict severity: %q", conflicts[0].Severity)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDetectTransportOwnerLockConflictsAllowsSwitchWhenPreviousOwnerDown(t *testing.T) {
|
||||
current := []TransportPolicyIntent{
|
||||
{SelectorType: "domain", SelectorValue: "example.com", ClientID: "c1"},
|
||||
}
|
||||
next := []TransportPolicyIntent{
|
||||
{SelectorType: "domain", SelectorValue: "example.com", ClientID: "c2"},
|
||||
}
|
||||
clients := []TransportClient{
|
||||
{ID: "c1", Status: TransportClientDown},
|
||||
{ID: "c2", Status: TransportClientUp},
|
||||
}
|
||||
|
||||
conflicts := detectTransportOwnerLockConflicts(current, next, clients)
|
||||
if len(conflicts) != 0 {
|
||||
t.Fatalf("expected no conflicts, got %#v", conflicts)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsTransportClientOwnerLockActive(t *testing.T) {
|
||||
if !isTransportClientOwnerLockActive(TransportClientUp) {
|
||||
t.Fatalf("up must be active")
|
||||
}
|
||||
if !isTransportClientOwnerLockActive(TransportClientStarting) {
|
||||
t.Fatalf("starting must be active")
|
||||
}
|
||||
if !isTransportClientOwnerLockActive(TransportClientDegraded) {
|
||||
t.Fatalf("degraded must be active")
|
||||
}
|
||||
if isTransportClientOwnerLockActive(TransportClientDown) {
|
||||
t.Fatalf("down must be inactive")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user