github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/command/agent/consul/version_checker_test.go (about) 1 package consul 2 3 import ( 4 "encoding/json" 5 "testing" 6 7 "github.com/hashicorp/nomad/ci" 8 ) 9 10 func TestConsulSupportsTLSSkipVerify(t *testing.T) { 11 ci.Parallel(t) 12 13 assertSupport := func(expected bool, blob string) { 14 self := map[string]map[string]interface{}{} 15 if err := json.Unmarshal([]byte("{"+blob+"}"), &self); err != nil { 16 t.Fatalf("invalid json: %v", err) 17 } 18 actual := supportsTLSSkipVerify(self) 19 if actual != expected { 20 t.Errorf("expected %t but got %t for:\n%s\n", expected, actual, blob) 21 } 22 } 23 24 // 0.6.4 25 assertSupport(false, `"Member": { 26 "Addr": "127.0.0.1", 27 "DelegateCur": 4, 28 "DelegateMax": 4, 29 "DelegateMin": 2, 30 "Name": "rusty", 31 "Port": 8301, 32 "ProtocolCur": 2, 33 "ProtocolMax": 3, 34 "ProtocolMin": 1, 35 "Status": 1, 36 "Tags": { 37 "build": "0.6.4:26a0ef8c", 38 "dc": "dc1", 39 "port": "8300", 40 "role": "consul", 41 "vsn": "2", 42 "vsn_max": "3", 43 "vsn_min": "1" 44 }}`) 45 46 // 0.7.0 47 assertSupport(false, `"Member": { 48 "Addr": "127.0.0.1", 49 "DelegateCur": 4, 50 "DelegateMax": 4, 51 "DelegateMin": 2, 52 "Name": "rusty", 53 "Port": 8301, 54 "ProtocolCur": 2, 55 "ProtocolMax": 4, 56 "ProtocolMin": 1, 57 "Status": 1, 58 "Tags": { 59 "build": "0.7.0:'a189091", 60 "dc": "dc1", 61 "port": "8300", 62 "role": "consul", 63 "vsn": "2", 64 "vsn_max": "3", 65 "vsn_min": "2" 66 }}`) 67 68 // 0.7.2 69 assertSupport(true, `"Member": { 70 "Addr": "127.0.0.1", 71 "DelegateCur": 4, 72 "DelegateMax": 4, 73 "DelegateMin": 2, 74 "Name": "rusty", 75 "Port": 8301, 76 "ProtocolCur": 2, 77 "ProtocolMax": 5, 78 "ProtocolMin": 1, 79 "Status": 1, 80 "Tags": { 81 "build": "0.7.2:'a9afa0c", 82 "dc": "dc1", 83 "port": "8300", 84 "role": "consul", 85 "vsn": "2", 86 "vsn_max": "3", 87 "vsn_min": "2" 88 }}`) 89 90 // 0.8.1 91 assertSupport(true, `"Member": { 92 "Addr": "127.0.0.1", 93 "DelegateCur": 4, 94 "DelegateMax": 5, 95 "DelegateMin": 2, 96 "Name": "rusty", 97 "Port": 8301, 98 "ProtocolCur": 2, 99 "ProtocolMax": 5, 100 "ProtocolMin": 1, 101 "Status": 1, 102 "Tags": { 103 "build": "0.8.1:'e9ca44d", 104 "dc": "dc1", 105 "id": "3ddc1b59-460e-a100-1d5c-ce3972122664", 106 "port": "8300", 107 "raft_vsn": "2", 108 "role": "consul", 109 "vsn": "2", 110 "vsn_max": "3", 111 "vsn_min": "2", 112 "wan_join_port": "8302" 113 }}`) 114 }