github.com/bigcommerce/nomad@v0.9.3-bc/command/agent/consul/version_checker_test.go (about)

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