(t *testing.T)
| 331 | } |
| 332 | |
| 333 | func TestSettingsTestEmail(t *testing.T) { |
| 334 | t.Parallel() |
| 335 | |
| 336 | scenarios := []tests.ApiScenario{ |
| 337 | { |
| 338 | Name: "unauthorized", |
| 339 | Method: http.MethodPost, |
| 340 | URL: "/api/settings/test/email", |
| 341 | Body: strings.NewReader(`{ |
| 342 | "template": "verification", |
| 343 | "email": "test@example.com" |
| 344 | }`), |
| 345 | ExpectedStatus: 401, |
| 346 | ExpectedContent: []string{`"data":{}`}, |
| 347 | ExpectedEvents: map[string]int{"*": 0}, |
| 348 | }, |
| 349 | { |
| 350 | Name: "authorized as regular user", |
| 351 | Method: http.MethodPost, |
| 352 | URL: "/api/settings/test/email", |
| 353 | Body: strings.NewReader(`{ |
| 354 | "template": "verification", |
| 355 | "email": "test@example.com" |
| 356 | }`), |
| 357 | Headers: map[string]string{ |
| 358 | "Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IjRxMXhsY2xtZmxva3UzMyIsInR5cGUiOiJhdXRoIiwiY29sbGVjdGlvbklkIjoiX3BiX3VzZXJzX2F1dGhfIiwiZXhwIjoyNTI0NjA0NDYxLCJyZWZyZXNoYWJsZSI6dHJ1ZX0.ZT3F0Z3iM-xbGgSG3LEKiEzHrPHr8t8IuHLZGGNuxLo", |
| 359 | }, |
| 360 | ExpectedStatus: 403, |
| 361 | ExpectedContent: []string{`"data":{}`}, |
| 362 | ExpectedEvents: map[string]int{"*": 0}, |
| 363 | }, |
| 364 | { |
| 365 | Name: "authorized as superuser (invalid body)", |
| 366 | Method: http.MethodPost, |
| 367 | URL: "/api/settings/test/email", |
| 368 | Body: strings.NewReader(`{`), |
| 369 | Headers: map[string]string{ |
| 370 | "Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6InN5d2JoZWNuaDQ2cmhtMCIsInR5cGUiOiJhdXRoIiwiY29sbGVjdGlvbklkIjoicGJjXzMxNDI2MzU4MjMiLCJleHAiOjI1MjQ2MDQ0NjEsInJlZnJlc2hhYmxlIjp0cnVlfQ.UXgO3j-0BumcugrFjbd7j0M4MQvbrLggLlcu_YNGjoY", |
| 371 | }, |
| 372 | ExpectedStatus: 400, |
| 373 | ExpectedContent: []string{`"data":{}`}, |
| 374 | ExpectedEvents: map[string]int{"*": 0}, |
| 375 | }, |
| 376 | { |
| 377 | Name: "authorized as superuser (empty json)", |
| 378 | Method: http.MethodPost, |
| 379 | URL: "/api/settings/test/email", |
| 380 | Body: strings.NewReader(`{}`), |
| 381 | Headers: map[string]string{ |
| 382 | "Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6InN5d2JoZWNuaDQ2cmhtMCIsInR5cGUiOiJhdXRoIiwiY29sbGVjdGlvbklkIjoicGJjXzMxNDI2MzU4MjMiLCJleHAiOjI1MjQ2MDQ0NjEsInJlZnJlc2hhYmxlIjp0cnVlfQ.UXgO3j-0BumcugrFjbd7j0M4MQvbrLggLlcu_YNGjoY", |
| 383 | }, |
| 384 | ExpectedStatus: 400, |
| 385 | ExpectedContent: []string{ |
| 386 | `"email":{"code":"validation_required"`, |
| 387 | `"template":{"code":"validation_required"`, |
| 388 | }, |
| 389 | ExpectedEvents: map[string]int{"*": 0}, |
| 390 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…