(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestAPIsPickerOptions(t *testing.T) { |
| 18 | tests := []struct { |
| 19 | name string |
| 20 | apis []*management.ResourceServer |
| 21 | apiError error |
| 22 | assertOutput func(t testing.TB, options pickerOptions) |
| 23 | assertError func(t testing.TB, err error) |
| 24 | }{ |
| 25 | { |
| 26 | name: "happy path", |
| 27 | apis: []*management.ResourceServer{ |
| 28 | { |
| 29 | ID: auth0.String("some-id-1"), |
| 30 | Identifier: auth0.String("some-audience-1"), |
| 31 | Name: auth0.String("some-name-1"), |
| 32 | }, |
| 33 | { |
| 34 | ID: auth0.String("some-id-2"), |
| 35 | Identifier: auth0.String("some-audience-2"), |
| 36 | Name: auth0.String("some-name-2"), |
| 37 | }, |
| 38 | }, |
| 39 | assertOutput: func(t testing.TB, options pickerOptions) { |
| 40 | assert.Len(t, options, 2) |
| 41 | assert.Equal(t, "some-name-1 (some-audience-1)", options[0].label) |
| 42 | assert.Equal(t, "some-id-1", options[0].value) |
| 43 | assert.Equal(t, "some-name-2 (some-audience-2)", options[1].label) |
| 44 | assert.Equal(t, "some-id-2", options[1].value) |
| 45 | }, |
| 46 | assertError: func(t testing.TB, err error) { |
| 47 | t.Fail() |
| 48 | }, |
| 49 | }, |
| 50 | { |
| 51 | name: "APIs with subject type authorization", |
| 52 | apis: []*management.ResourceServer{ |
| 53 | { |
| 54 | ID: auth0.String("api-id-1"), |
| 55 | Identifier: auth0.String("https://api.example.com"), |
| 56 | Name: auth0.String("Example API"), |
| 57 | SubjectTypeAuthorization: &management.ResourceServerSubjectTypeAuthorization{ |
| 58 | User: &management.ResourceServerSubjectTypeAuthorizationUser{ |
| 59 | Policy: auth0.String("allow_all"), |
| 60 | }, |
| 61 | Client: &management.ResourceServerSubjectTypeAuthorizationClient{ |
| 62 | Policy: auth0.String("deny_all"), |
| 63 | }, |
| 64 | }, |
| 65 | }, |
| 66 | { |
| 67 | ID: auth0.String("api-id-2"), |
| 68 | Identifier: auth0.String("https://secure-api.example.com"), |
| 69 | Name: auth0.String("Secure API"), |
| 70 | SubjectTypeAuthorization: &management.ResourceServerSubjectTypeAuthorization{ |
| 71 | User: &management.ResourceServerSubjectTypeAuthorizationUser{ |
| 72 | Policy: auth0.String("require_client_grant"), |
| 73 | }, |
| 74 | Client: &management.ResourceServerSubjectTypeAuthorizationClient{ |
nothing calls this directly
no test coverage detected