(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestGitlabDefaults(t *testing.T) { |
| 17 | t.Parallel() |
| 18 | |
| 19 | // The default cloud setup. Copying this here as hard coded |
| 20 | // values. |
| 21 | cloud := func() codersdk.ExternalAuthConfig { |
| 22 | return codersdk.ExternalAuthConfig{ |
| 23 | Type: string(codersdk.EnhancedExternalAuthProviderGitLab), |
| 24 | ID: string(codersdk.EnhancedExternalAuthProviderGitLab), |
| 25 | AuthURL: "https://gitlab.com/oauth/authorize", |
| 26 | TokenURL: "https://gitlab.com/oauth/token", |
| 27 | ValidateURL: "https://gitlab.com/oauth/token/info", |
| 28 | RevokeURL: "https://gitlab.com/oauth/revoke", |
| 29 | DisplayName: "GitLab", |
| 30 | DisplayIcon: "/icon/gitlab.svg", |
| 31 | Regex: `^(https?://)?gitlab\.com(/.*)?$`, |
| 32 | APIBaseURL: "https://gitlab.com/api/v4", |
| 33 | Scopes: []string{"write_repository", "read_api"}, |
| 34 | CodeChallengeMethodsSupported: []string{string(promoauth.PKCEChallengeMethodSha256)}, |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | tests := []struct { |
| 39 | name string |
| 40 | input codersdk.ExternalAuthConfig |
| 41 | expected codersdk.ExternalAuthConfig |
| 42 | mutateExpected func(*codersdk.ExternalAuthConfig) |
| 43 | }{ |
| 44 | // Cloud |
| 45 | { |
| 46 | name: "OnlyType", |
| 47 | input: codersdk.ExternalAuthConfig{ |
| 48 | Type: string(codersdk.EnhancedExternalAuthProviderGitLab), |
| 49 | }, |
| 50 | expected: cloud(), |
| 51 | }, |
| 52 | { |
| 53 | // If someone was to manually configure the gitlab cli. |
| 54 | name: "CloudByConfig", |
| 55 | input: codersdk.ExternalAuthConfig{ |
| 56 | Type: string(codersdk.EnhancedExternalAuthProviderGitLab), |
| 57 | AuthURL: "https://gitlab.com/oauth/authorize", |
| 58 | }, |
| 59 | expected: cloud(), |
| 60 | }, |
| 61 | { |
| 62 | // Changing some of the defaults of the cloud option |
| 63 | name: "CloudWithChanges", |
| 64 | input: codersdk.ExternalAuthConfig{ |
| 65 | Type: string(codersdk.EnhancedExternalAuthProviderGitLab), |
| 66 | // Adding an extra query param intentionally to break simple |
| 67 | // string comparisons. |
| 68 | AuthURL: "https://gitlab.com/oauth/authorize?foo=bar", |
| 69 | DisplayName: "custom", |
| 70 | Regex: ".*", |
| 71 | }, |
| 72 | expected: cloud(), |
| 73 | mutateExpected: func(config *codersdk.ExternalAuthConfig) { |
nothing calls this directly
no test coverage detected