MCPcopy
hub / github.com/cloudflare/cloudflared / TestUpdateConfiguration

Function TestUpdateConfiguration

orchestration/orchestrator_test.go:57–187  ·  view source on GitHub ↗

TestUpdateConfiguration tests that - configurations can be deserialized - proxy can be updated - last applied version and error are returned - configurations can be deserialized - receiving an old version is noop

(t *testing.T)

Source from the content-addressed store, hash-verified

55// - configurations can be deserialized
56// - receiving an old version is noop
57func TestUpdateConfiguration(t *testing.T) {
58 originDialer := ingress.NewOriginDialer(ingress.OriginConfig{
59 DefaultDialer: testDefaultDialer,
60 TCPWriteTimeout: 1 * time.Second,
61 }, &testLogger)
62 initConfig := &Config{
63 Ingress: &ingress.Ingress{},
64 OriginDialerService: originDialer,
65 }
66 orchestrator, err := NewOrchestrator(t.Context(), initConfig, testTags, []ingress.Rule{ingress.NewManagementRule(management.New("management.argotunnel.com", false, "1.1.1.1:80", uuid.Nil, "", &testLogger, nil))}, &testLogger)
67 require.NoError(t, err)
68 initOriginProxy, err := orchestrator.GetOriginProxy()
69 require.NoError(t, err)
70 require.Implements(t, (*connection.OriginProxy)(nil), initOriginProxy)
71
72 configJSONV2 := []byte(`
73{
74 "unknown_field": "not_deserialized",
75 "originRequest": {
76 "connectTimeout": 90,
77 "noHappyEyeballs": true
78 },
79 "ingress": [
80 {
81 "hostname": "jira.tunnel.org",
82 "path": "^\/login",
83 "service": "http://192.16.19.1:443",
84 "originRequest": {
85 "noTLSVerify": true,
86 "connectTimeout": 10
87 }
88 },
89 {
90 "hostname": "jira.tunnel.org",
91 "service": "http://172.32.20.6:80",
92 "originRequest": {
93 "noTLSVerify": true,
94 "connectTimeout": 30
95 }
96 },
97 {
98 "service": "http_status:404"
99 }
100 ],
101 "warp-routing": {
102 "connectTimeout": 10
103 }
104}
105`)
106
107 updateWithValidation(t, orchestrator, 2, configJSONV2)
108 configV2 := orchestrator.config
109 // Validate internal ingress rules
110 require.Equal(t, "management.argotunnel.com", configV2.Ingress.InternalRules[0].Hostname)
111 require.True(t, configV2.Ingress.InternalRules[0].Matches("management.argotunnel.com", "/ping"))
112 require.Equal(t, "management", configV2.Ingress.InternalRules[0].Service.String())
113 // Validate ingress rule 0
114 require.Equal(t, "jira.tunnel.org", configV2.Ingress.Rules[0].Hostname)

Callers

nothing calls this directly

Calls 13

GetOriginProxyMethod · 0.95
UpdateConfigMethod · 0.95
NewOriginDialerFunction · 0.92
NewManagementRuleFunction · 0.92
NewFunction · 0.92
NewOrchestratorFunction · 0.85
updateWithValidationFunction · 0.85
MatchesMethod · 0.80
LenMethod · 0.80
ContextMethod · 0.65
EqualMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected