(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestRecordAuthRefresh(t *testing.T) { |
| 12 | t.Parallel() |
| 13 | |
| 14 | scenarios := []tests.ApiScenario{ |
| 15 | { |
| 16 | Name: "unauthorized", |
| 17 | Method: http.MethodPost, |
| 18 | URL: "/api/collections/users/auth-refresh", |
| 19 | ExpectedStatus: 401, |
| 20 | ExpectedContent: []string{`"data":{}`}, |
| 21 | ExpectedEvents: map[string]int{"*": 0}, |
| 22 | }, |
| 23 | { |
| 24 | Name: "superuser trying to refresh the auth of another auth collection", |
| 25 | Method: http.MethodPost, |
| 26 | URL: "/api/collections/users/auth-refresh", |
| 27 | Headers: map[string]string{ |
| 28 | "Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6InN5d2JoZWNuaDQ2cmhtMCIsInR5cGUiOiJhdXRoIiwiY29sbGVjdGlvbklkIjoicGJjXzMxNDI2MzU4MjMiLCJleHAiOjI1MjQ2MDQ0NjEsInJlZnJlc2hhYmxlIjp0cnVlfQ.UXgO3j-0BumcugrFjbd7j0M4MQvbrLggLlcu_YNGjoY", |
| 29 | }, |
| 30 | ExpectedStatus: 403, |
| 31 | ExpectedContent: []string{`"data":{}`}, |
| 32 | ExpectedEvents: map[string]int{"*": 0}, |
| 33 | }, |
| 34 | { |
| 35 | Name: "auth record + not an auth collection", |
| 36 | Method: http.MethodPost, |
| 37 | URL: "/api/collections/demo1/auth-refresh", |
| 38 | Headers: map[string]string{ |
| 39 | "Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IjRxMXhsY2xtZmxva3UzMyIsInR5cGUiOiJhdXRoIiwiY29sbGVjdGlvbklkIjoiX3BiX3VzZXJzX2F1dGhfIiwiZXhwIjoyNTI0NjA0NDYxLCJyZWZyZXNoYWJsZSI6dHJ1ZX0.ZT3F0Z3iM-xbGgSG3LEKiEzHrPHr8t8IuHLZGGNuxLo", |
| 40 | }, |
| 41 | ExpectedStatus: 403, |
| 42 | ExpectedContent: []string{`"data":{}`}, |
| 43 | ExpectedEvents: map[string]int{"*": 0}, |
| 44 | }, |
| 45 | { |
| 46 | Name: "auth record + different auth collection", |
| 47 | Method: http.MethodPost, |
| 48 | URL: "/api/collections/clients/auth-refresh?expand=rel,missing", |
| 49 | Headers: map[string]string{ |
| 50 | "Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IjRxMXhsY2xtZmxva3UzMyIsInR5cGUiOiJhdXRoIiwiY29sbGVjdGlvbklkIjoiX3BiX3VzZXJzX2F1dGhfIiwiZXhwIjoyNTI0NjA0NDYxLCJyZWZyZXNoYWJsZSI6dHJ1ZX0.ZT3F0Z3iM-xbGgSG3LEKiEzHrPHr8t8IuHLZGGNuxLo", |
| 51 | }, |
| 52 | ExpectedStatus: 403, |
| 53 | ExpectedContent: []string{`"data":{}`}, |
| 54 | ExpectedEvents: map[string]int{"*": 0}, |
| 55 | }, |
| 56 | { |
| 57 | Name: "auth record + same auth collection as the token", |
| 58 | Method: http.MethodPost, |
| 59 | URL: "/api/collections/users/auth-refresh?expand=rel,missing", |
| 60 | Headers: map[string]string{ |
| 61 | "Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IjRxMXhsY2xtZmxva3UzMyIsInR5cGUiOiJhdXRoIiwiY29sbGVjdGlvbklkIjoiX3BiX3VzZXJzX2F1dGhfIiwiZXhwIjoyNTI0NjA0NDYxLCJyZWZyZXNoYWJsZSI6dHJ1ZX0.ZT3F0Z3iM-xbGgSG3LEKiEzHrPHr8t8IuHLZGGNuxLo", |
| 62 | }, |
| 63 | ExpectedStatus: 200, |
| 64 | ExpectedContent: []string{ |
| 65 | `"token":`, |
| 66 | `"record":`, |
| 67 | `"id":"4q1xlclmfloku33"`, |
| 68 | `"emailVisibility":false`, |
nothing calls this directly
no test coverage detected
searching dependent graphs…