@@ -519,14 +519,12 @@ func TestObfuscationConfigs(t *testing.T) {
519
519
// Prepare a test cases
520
520
streamID := uuid .New ()
521
521
type testCase struct {
522
- name string
523
522
request akinet.HTTPRequest
524
523
response akinet.HTTPResponse
525
524
expectedWitnesses * api_spec.Witness
526
525
}
527
- testCases := []testCase {
528
- {
529
- name : "no sensitive data" ,
526
+ testCases := map [string ]testCase {
527
+ "no sensitive data" : {
530
528
request : akinet.HTTPRequest {
531
529
StreamID : streamID ,
532
530
Seq : 1204 ,
@@ -589,8 +587,7 @@ func TestObfuscationConfigs(t *testing.T) {
589
587
},
590
588
},
591
589
},
592
- {
593
- name : "sensitive data in header, query param, cookie and URL path" ,
590
+ "sensitive data in header, query param, cookie and URL path" : {
594
591
request : akinet.HTTPRequest {
595
592
StreamID : streamID ,
596
593
Seq : 1204 ,
@@ -687,8 +684,7 @@ func TestObfuscationConfigs(t *testing.T) {
687
684
},
688
685
},
689
686
},
690
- {
691
- name : "sensitive data in body" ,
687
+ "sensitive data in body" : {
692
688
request : akinet.HTTPRequest {
693
689
StreamID : streamID ,
694
690
Seq : 1204 ,
@@ -763,8 +759,7 @@ func TestObfuscationConfigs(t *testing.T) {
763
759
},
764
760
},
765
761
},
766
- {
767
- name : "struct with sensitive keys and values" ,
762
+ "struct with sensitive keys and values" : {
768
763
request : akinet.HTTPRequest {
769
764
StreamID : streamID ,
770
765
Seq : 1204 ,
@@ -869,8 +864,7 @@ func TestObfuscationConfigs(t *testing.T) {
869
864
},
870
865
},
871
866
},
872
- {
873
- name : "list with sensitive keys and values" ,
867
+ "list with sensitive keys and values" : {
874
868
request : akinet.HTTPRequest {
875
869
StreamID : streamID ,
876
870
Seq : 1204 ,
@@ -986,8 +980,7 @@ func TestObfuscationConfigs(t *testing.T) {
986
980
},
987
981
},
988
982
},
989
- {
990
- name : "multipart data, no sensitive data" ,
983
+ "multipart data, no sensitive data" : {
991
984
request : akinet.HTTPRequest {
992
985
StreamID : streamID ,
993
986
Seq : 1204 ,
@@ -1062,8 +1055,7 @@ func TestObfuscationConfigs(t *testing.T) {
1062
1055
},
1063
1056
},
1064
1057
},
1065
- {
1066
- name : "multipart data, with sensitive data" ,
1058
+ "multipart data, with sensitive data" : {
1067
1059
request : akinet.HTTPRequest {
1068
1060
StreamID : streamID ,
1069
1061
Seq : 1204 ,
@@ -1152,6 +1144,75 @@ func TestObfuscationConfigs(t *testing.T) {
1152
1144
},
1153
1145
},
1154
1146
},
1147
+ "null value" : {
1148
+ request : akinet.HTTPRequest {
1149
+ StreamID : streamID ,
1150
+ Seq : 1204 ,
1151
+ Method : "POST" ,
1152
+ URL : & url.URL {
1153
+ Path : "/" ,
1154
+ },
1155
+ Host : "example.com" ,
1156
+ Header : map [string ][]string {
1157
+ "Content-Type" : {"application/json" },
1158
+ },
1159
+ Body : memview .New ([]byte (`
1160
+ {
1161
+ "null": null
1162
+ }
1163
+ ` )),
1164
+ },
1165
+ response : akinet.HTTPResponse {
1166
+ StreamID : streamID ,
1167
+ Seq : 1204 ,
1168
+ StatusCode : 404 ,
1169
+ Header : map [string ][]string {
1170
+ "Content-Type" : {"application/json" },
1171
+ },
1172
+ Body : memview .New ([]byte (`
1173
+ {
1174
+ "null": null
1175
+ }
1176
+ ` )),
1177
+ },
1178
+ expectedWitnesses : & pb.Witness {
1179
+ Method : & pb.Method {
1180
+ Id : & pb.MethodID {
1181
+ ApiType : pb .ApiType_HTTP_REST ,
1182
+ },
1183
+ Args : map [string ]* pb.Data {
1184
+ "sLSDNjJ5umQ=" : newTestBodySpecFromStruct (
1185
+ 0 ,
1186
+ pb .HTTPBody_JSON ,
1187
+ "application/json" ,
1188
+ map [string ]* pb.Data {
1189
+ "null" : spec_util .NoneData ,
1190
+ },
1191
+ ),
1192
+ },
1193
+ Responses : map [string ]* pb.Data {
1194
+ "2drZdoQw74E=" : newTestBodySpecFromStruct (
1195
+ 404 ,
1196
+ pb .HTTPBody_JSON ,
1197
+ "application/json" ,
1198
+ map [string ]* pb.Data {
1199
+ "null" : spec_util .NoneData ,
1200
+ },
1201
+ ),
1202
+ },
1203
+ Meta : & pb.MethodMeta {
1204
+ Meta : & pb.MethodMeta_Http {
1205
+ Http : & pb.HTTPMethodMeta {
1206
+ Method : "POST" ,
1207
+ PathTemplate : "/" ,
1208
+ Host : "example.com" ,
1209
+ Obfuscation : api_spec .HTTPMethodMeta_NONE ,
1210
+ },
1211
+ },
1212
+ },
1213
+ },
1214
+ },
1215
+ },
1155
1216
}
1156
1217
1157
1218
// Setup for running tests
@@ -1167,8 +1228,10 @@ func TestObfuscationConfigs(t *testing.T) {
1167
1228
AnyTimes ().
1168
1229
Return (nil )
1169
1230
1170
- for i , testCase := range testCases {
1171
- fmt .Println ("Running test case: " , testCase .name )
1231
+ i := - 1
1232
+ for name , testCase := range testCases {
1233
+ i ++
1234
+ fmt .Println ("Running test case: " , name )
1172
1235
1173
1236
req := akinet.ParsedNetworkTraffic {Content : testCase .request }
1174
1237
resp := akinet.ParsedNetworkTraffic {Content : testCase .response }
0 commit comments