TestNewLocalConfig_MarshalJSON tests that we are able to converte a compiled and validated config back into an "unvalidated" format which is compatible with Remote Managed configurations.
(t *testing.T)
| 14 | // TestNewLocalConfig_MarshalJSON tests that we are able to converte a compiled and validated config back |
| 15 | // into an "unvalidated" format which is compatible with Remote Managed configurations. |
| 16 | func TestNewLocalConfig_MarshalJSON(t *testing.T) { |
| 17 | rawConfig := []byte(` |
| 18 | { |
| 19 | "originRequest": { |
| 20 | "connectTimeout": 160, |
| 21 | "httpHostHeader": "default" |
| 22 | }, |
| 23 | "ingress": [ |
| 24 | { |
| 25 | "hostname": "tun.example.com", |
| 26 | "service": "https://localhost:8000" |
| 27 | }, |
| 28 | { |
| 29 | "hostname": "*", |
| 30 | "service": "https://localhost:8001", |
| 31 | "originRequest": { |
| 32 | "connectTimeout": 121, |
| 33 | "tlsTimeout": 2, |
| 34 | "noHappyEyeballs": false, |
| 35 | "tcpKeepAlive": 2, |
| 36 | "keepAliveConnections": 2, |
| 37 | "keepAliveTimeout": 2, |
| 38 | "httpHostHeader": "def", |
| 39 | "originServerName": "b2", |
| 40 | "caPool": "/tmp/path1", |
| 41 | "noTLSVerify": false, |
| 42 | "disableChunkedEncoding": false, |
| 43 | "bastionMode": false, |
| 44 | "proxyAddress": "interface", |
| 45 | "proxyPort": 200, |
| 46 | "proxyType": "", |
| 47 | "ipRules": [ |
| 48 | { |
| 49 | "prefix": "10.0.0.0/16", |
| 50 | "ports": [3000, 3030], |
| 51 | "allow": false |
| 52 | }, |
| 53 | { |
| 54 | "prefix": "192.16.0.0/24", |
| 55 | "ports": [5000, 5050], |
| 56 | "allow": true |
| 57 | } |
| 58 | ] |
| 59 | } |
| 60 | } |
| 61 | ], |
| 62 | "warp-routing": { |
| 63 | "connectTimeout": 1 |
| 64 | } |
| 65 | } |
| 66 | `) |
| 67 | |
| 68 | var expectedConfig ingress.RemoteConfig |
| 69 | err := json.Unmarshal(rawConfig, &expectedConfig) |
| 70 | require.NoError(t, err) |
| 71 | |
| 72 | c := &newLocalConfig{ |
| 73 | RemoteConfig: expectedConfig, |