@@ -21,61 +21,59 @@ func TestBootstrap(t *testing.T) {
2121 http .Error (w , "Invalid authorization header" , http .StatusUnauthorized )
2222 return
2323 }
24+ resp := `
25+ {
26+ "thing_id": "e22c383a-d2ab-47c1-89cd-903955da993d",
27+ "thing_key": "fc987711-1828-461b-aa4b-16d5b2c642fe",
28+ "channels": [
29+ %s
30+ ],
31+ "content": "{\"agent\":{\"edgex\":{\"url\":\"http://localhost:48090/api/v1/\"},\"heartbeat\":{\"interval\":\"30s\"},\"log\":{\"level\":\"debug\"},\"mqtt\":{\"mtls\":false,\"qos\":0,\"retain\":false,\"skip_tls_ver\":true,\"url\":\"tcp://mainflux-domain.com:1883\"},\"server\":{\"nats_url\":\"localhost:4222\",\"port\":\"9000\"},\"terminal\":{\"session_timeout\":\"30s\"}},\"export\":{\"exp\":{\"cache_db\":\"0\",\"cache_pass\":\"\",\"cache_url\":\"localhost:6379\",\"log_level\":\"debug\",\"nats\":\"nats://localhost:4222\",\"port\":\"8172\"},\"mqtt\":{\"ca_path\":\"ca.crt\",\"cert_path\":\"thing.crt\",\"channel\":\"\",\"host\":\"tcp://mainflux-domain.com:1883\",\"mtls\":false,\"password\":\"\",\"priv_key_path\":\"thing.key\",\"qos\":0,\"retain\":false,\"skip_tls_ver\":false,\"username\":\"\"},\"routes\":[{\"mqtt_topic\":\"\",\"nats_topic\":\"channels\",\"subtopic\":\"\",\"type\":\"mfx\",\"workers\":10},{\"mqtt_topic\":\"\",\"nats_topic\":\"export\",\"subtopic\":\"\",\"type\":\"default\",\"workers\":10}]}}"
32+ }
33+ `
2434 if r .Header .Get ("Authorization" ) == "Thing invalidChannels" {
2535 // Simulate a malformed response.
26- resp := `
36+ channels := `
2737 {
28- "thing_id": "e22c383a-d2ab-47c1-89cd-903955da993d",
29- "thing_key": "fc987711-1828-461b-aa4b-16d5b2c642fe",
30- "channels": [
31- {
32- "id": "fa5f9ba8-a1fc-4380-9edb-d0c23eaa24ec",
33- "name": "control-channel",
34- "metadata": {
35- "type": "control"
36- }
37- }
38- ],
39- "content": "{\"agent\":{\"edgex\":{\"url\":\"http://localhost:48090/api/v1/\"},\"heartbeat\":{\"interval\":\"30s\"},\"log\":{\"level\":\"debug\"},\"mqtt\":{\"mtls\":false,\"qos\":0,\"retain\":false,\"skip_tls_ver\":true,\"url\":\"tcp://mainflux-domain.com:1883\"},\"server\":{\"nats_url\":\"localhost:4222\",\"port\":\"9000\"},\"terminal\":{\"session_timeout\":\"30s\"}},\"export\":{\"exp\":{\"cache_db\":\"0\",\"cache_pass\":\"\",\"cache_url\":\"localhost:6379\",\"log_level\":\"debug\",\"nats\":\"nats://localhost:4222\",\"port\":\"8172\"},\"mqtt\":{\"ca_path\":\"ca.crt\",\"cert_path\":\"thing.crt\",\"channel\":\"\",\"host\":\"tcp://mainflux-domain.com:1883\",\"mtls\":false,\"password\":\"\",\"priv_key_path\":\"thing.key\",\"qos\":0,\"retain\":false,\"skip_tls_ver\":false,\"username\":\"\"},\"routes\":[{\"mqtt_topic\":\"\",\"nats_topic\":\"channels\",\"subtopic\":\"\",\"type\":\"mfx\",\"workers\":10},{\"mqtt_topic\":\"\",\"nats_topic\":\"export\",\"subtopic\":\"\",\"type\":\"default\",\"workers\":10}]}}"
40- }
38+ "id": "fa5f9ba8-a1fc-4380-9edb-d0c23eaa24ec",
39+ "name": "control-channel",
40+ "metadata": {
41+ "type": "control"
42+ }
43+ }
4144 `
45+ resp = fmt .Sprintf (resp , channels )
4246 w .WriteHeader (http .StatusOK )
4347 if _ , err := io .WriteString (w , resp ); err != nil {
4448 t .Errorf (err .Error ())
4549 }
4650 return
4751 }
4852 // Simulate a successful response.
49- resp := `
53+ channels := `
5054 {
51- "thing_id": "e22c383a-d2ab-47c1-89cd-903955da993d",
52- "thing_key": "fc987711-1828-461b-aa4b-16d5b2c642fe",
53- "channels": [
54- {
55- "id": "fa5f9ba8-a1fc-4380-9edb-d0c23eaa24ec",
56- "name": "control-channel",
57- "metadata": {
58- "type": "control"
59- }
60- },
61- {
62- "id": "24e5473e-3cbe-43d9-8a8b-a725ff918c0e",
63- "name": "data-channel",
64- "metadata": {
65- "type": "data"
66- }
67- },
68- {
69- "id": "1eac45c2-0f72-4089-b255-ebd2e5732bbb",
70- "name": "export-channel",
71- "metadata": {
72- "type": "export"
73- }
74- }
75- ],
76- "content": "{\"agent\":{\"edgex\":{\"url\":\"http://localhost:48090/api/v1/\"},\"heartbeat\":{\"interval\":\"30s\"},\"log\":{\"level\":\"debug\"},\"mqtt\":{\"mtls\":false,\"qos\":0,\"retain\":false,\"skip_tls_ver\":true,\"url\":\"tcp://mainflux-domain.com:1883\"},\"server\":{\"nats_url\":\"localhost:4222\",\"port\":\"9000\"},\"terminal\":{\"session_timeout\":\"30s\"}},\"export\":{\"exp\":{\"cache_db\":\"0\",\"cache_pass\":\"\",\"cache_url\":\"localhost:6379\",\"log_level\":\"debug\",\"nats\":\"nats://localhost:4222\",\"port\":\"8172\"},\"mqtt\":{\"ca_path\":\"ca.crt\",\"cert_path\":\"thing.crt\",\"channel\":\"\",\"host\":\"tcp://mainflux-domain.com:1883\",\"mtls\":false,\"password\":\"\",\"priv_key_path\":\"thing.key\",\"qos\":0,\"retain\":false,\"skip_tls_ver\":false,\"username\":\"\"},\"routes\":[{\"mqtt_topic\":\"\",\"nats_topic\":\"channels\",\"subtopic\":\"\",\"type\":\"mfx\",\"workers\":10},{\"mqtt_topic\":\"\",\"nats_topic\":\"export\",\"subtopic\":\"\",\"type\":\"default\",\"workers\":10}]}}"
55+ "id": "fa5f9ba8-a1fc-4380-9edb-d0c23eaa24ec",
56+ "name": "control-channel",
57+ "metadata": {
58+ "type": "control"
59+ }
60+ },
61+ {
62+ "id": "24e5473e-3cbe-43d9-8a8b-a725ff918c0e",
63+ "name": "data-channel",
64+ "metadata": {
65+ "type": "data"
66+ }
67+ },
68+ {
69+ "id": "1eac45c2-0f72-4089-b255-ebd2e5732bbb",
70+ "name": "export-channel",
71+ "metadata": {
72+ "type": "export"
73+ }
7774 }
7875 `
76+ resp = fmt .Sprintf (resp , channels )
7977 w .WriteHeader (http .StatusOK )
8078 if _ , err := io .WriteString (w , resp ); err != nil {
8179 t .Errorf (err .Error ())
0 commit comments