88 "github.com/dghubble/sling"
99 log "github.com/sirupsen/logrus"
1010 "github.com/stretchr/testify/assert"
11- "gopkg.in/tomb.v2"
1211 "gopkg.in/yaml.v2"
1312)
1413
@@ -267,15 +266,15 @@ func TestRegisterMachine(t *testing.T) {
267266 ApiVersion : "v1" ,
268267 RegisterPath : "register" ,
269268 BaseURL : "https://my_testendpoint.com" ,
270- CfgUser : "machine_id " ,
269+ CfgUser : "machineid " ,
271270 CfgPassword : "machine_password" ,
272271 Creds : ApiCreds {
273272 Profile : "crowdsec/test1,crowdsec/test2" ,
274273 },
275274 Http : sling .New ().Client (newMockClient ()).Base (apiBaseURL ),
276275 },
277276 expectedAPICreds : & ApiCreds {
278- User : "machine_id " ,
277+ User : "machineid " ,
279278 Password : "machine_password" ,
280279 Profile : "crowdsec/test1,crowdsec/test2" ,
281280 },
@@ -287,38 +286,24 @@ func TestRegisterMachine(t *testing.T) {
287286 ApiVersion : "v1" ,
288287 RegisterPath : "unknown_path" ,
289288 BaseURL : "https://my_testendpoint.com" ,
290- CfgUser : "machine_id " ,
289+ CfgUser : "machineid " ,
291290 CfgPassword : "machine_password" ,
292291 Creds : ApiCreds {
293- User : "machine_id " ,
292+ User : "machineid " ,
294293 Password : "machine_password" ,
295294 Profile : "crowdsec/test1,crowdsec/test2" ,
296295 },
297296 Http : sling .New ().Client (newMockClient ()).Base (apiBaseURL ),
298297 },
299298 },
300- {
301- name : "api register malformed response" ,
302- expectedErr : true ,
303- givenAPICtx : & ApiCtx {
304- ApiVersion : "v1" ,
305- RegisterPath : "malformed_response" ,
306- BaseURL : "https://my_testendpoint.com" ,
307- Creds : ApiCreds {
308- Profile : "crowdsec/test1,crowdsec/test2" ,
309- },
310- Http : sling .New ().Client (newMockClient ()).Base (apiBaseURL ),
311- PusherTomb : tomb.Tomb {},
312- },
313- },
314299 {
315300 name : "api register bad response" ,
316301 expectedErr : true ,
317302 givenAPICtx : & ApiCtx {
318303 ApiVersion : "v1" ,
319304 RegisterPath : "bad_response" ,
320305 BaseURL : "https://my_testendpoint.com" ,
321- CfgUser : "machine_id " ,
306+ CfgUser : "machineid " ,
322307 CfgPassword : "machine_password" ,
323308 Creds : ApiCreds {
324309 Profile : "crowdsec/test1,crowdsec/test2" ,
@@ -329,6 +314,7 @@ func TestRegisterMachine(t *testing.T) {
329314 }
330315
331316 for _ , test := range tests {
317+ log .Printf ("test '%s'" , test .name )
332318 err := test .givenAPICtx .RegisterMachine (test .givenAPICtx .CfgUser , test .givenAPICtx .CfgPassword )
333319 if ! test .expectedErr && err != nil {
334320 t .Fatalf ("test '%s' failed : %s" , test .name , err )
@@ -360,15 +346,15 @@ func TestResetPassword(t *testing.T) {
360346 ApiVersion : "v1" ,
361347 ResetPwdPath : "resetpassword" ,
362348 BaseURL : "https://my_testendpoint.com" ,
363- CfgUser : "machine_id " ,
349+ CfgUser : "machineid " ,
364350 CfgPassword : "new_machine_password" ,
365351 Creds : ApiCreds {
366352 Profile : "crowdsec/test1,crowdsec/test2" ,
367353 },
368354 Http : sling .New ().Client (newMockClient ()).Base (apiBaseURL ),
369355 },
370356 expectedAPICreds : & ApiCreds {
371- User : "machine_id " ,
357+ User : "machineid " ,
372358 Password : "new_machine_password" ,
373359 Profile : "crowdsec/test1,crowdsec/test2" ,
374360 },
@@ -380,38 +366,24 @@ func TestResetPassword(t *testing.T) {
380366 ApiVersion : "v1" ,
381367 ResetPwdPath : "unknown_path" ,
382368 BaseURL : "https://my_testendpoint.com" ,
383- CfgUser : "machine_id " ,
369+ CfgUser : "machineid " ,
384370 CfgPassword : "machine_password" ,
385371 Creds : ApiCreds {
386- User : "machine_id " ,
372+ User : "machineid " ,
387373 Password : "machine_password" ,
388374 Profile : "crowdsec/test1,crowdsec/test2" ,
389375 },
390376 Http : sling .New ().Client (newMockClient ()).Base (apiBaseURL ),
391377 },
392378 },
393- {
394- name : "api reset password malformed response" ,
395- expectedErr : true ,
396- givenAPICtx : & ApiCtx {
397- ApiVersion : "v1" ,
398- ResetPwdPath : "malformed_response" ,
399- BaseURL : "https://my_testendpoint.com" ,
400- Creds : ApiCreds {
401- Profile : "crowdsec/test1,crowdsec/test2" ,
402- },
403- Http : sling .New ().Client (newMockClient ()).Base (apiBaseURL ),
404- PusherTomb : tomb.Tomb {},
405- },
406- },
407379 {
408380 name : "api reset password bad response" ,
409381 expectedErr : true ,
410382 givenAPICtx : & ApiCtx {
411383 ApiVersion : "v1" ,
412384 ResetPwdPath : "bad_response" ,
413385 BaseURL : "https://my_testendpoint.com" ,
414- CfgUser : "machine_id " ,
386+ CfgUser : "machineid " ,
415387 CfgPassword : "machine_password" ,
416388 Creds : ApiCreds {
417389 Profile : "crowdsec/test1,crowdsec/test2" ,
@@ -426,7 +398,7 @@ func TestResetPassword(t *testing.T) {
426398 ApiVersion : "v1" ,
427399 ResetPwdPath : "resestpassword_unknown_user" ,
428400 BaseURL : "https://my_testendpoint.com" ,
429- CfgUser : "machine_id " ,
401+ CfgUser : "machineid " ,
430402 CfgPassword : "machine_password" ,
431403 Creds : ApiCreds {
432404 Profile : "crowdsec/test1,crowdsec/test2" ,
0 commit comments