MCPcopy Index your code
hub / github.com/coder/coder / TestExternalAuthYAMLConfig

Function TestExternalAuthYAMLConfig

codersdk/deployment_test.go:797–872  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

795var testData embed.FS
796
797func TestExternalAuthYAMLConfig(t *testing.T) {
798 t.Parallel()
799
800 if runtime.GOOS == "windows" {
801 // The windows marshal function uses different line endings.
802 // Not worth the effort getting this to work on windows.
803 t.SkipNow()
804 }
805
806 file := func(t *testing.T, name string) string {
807 data, err := testData.ReadFile(fmt.Sprintf("testdata/%s", name))
808 require.NoError(t, err, "read testdata file %q", name)
809 return string(data)
810 }
811 githubCfg := codersdk.ExternalAuthConfig{
812 Type: "github",
813 ClientID: "client_id",
814 ClientSecret: "client_secret",
815 ID: "id",
816 AuthURL: "https://example.com/auth",
817 TokenURL: "https://example.com/token",
818 ValidateURL: "https://example.com/validate",
819 RevokeURL: "https://example.com/revoke",
820 AppInstallURL: "https://example.com/install",
821 AppInstallationsURL: "https://example.com/installations",
822 NoRefresh: true,
823 Scopes: []string{"user:email", "read:org"},
824 ExtraTokenKeys: []string{"extra", "token"},
825 DeviceFlow: true,
826 DeviceCodeURL: "https://example.com/device",
827 Regex: "^https://example.com/.*$",
828 DisplayName: "GitHub",
829 DisplayIcon: "/static/icons/github.svg",
830 MCPURL: "https://api.githubcopilot.com/mcp/",
831 MCPToolAllowRegex: ".*",
832 MCPToolDenyRegex: "create_gist",
833 CodeChallengeMethodsSupported: []string{"S256"},
834 }
835
836 // Input the github section twice for testing a slice of configs.
837 inputYAML := func() string {
838 f := file(t, "githubcfg.yaml")
839 lines := strings.SplitN(f, "\n", 2)
840 // Append github config twice
841 return f + lines[1]
842 }()
843
844 expected := []codersdk.ExternalAuthConfig{
845 githubCfg, githubCfg,
846 }
847
848 dv := codersdk.DeploymentValues{}
849 opts := dv.Options()
850 // replace any tabs with the proper space indentation
851 inputYAML = strings.ReplaceAll(inputYAML, "\t", " ")
852
853 // This is the order things are done in the cli, so just
854 // keep it the same.

Callers

nothing calls this directly

Calls 9

OptionsMethod · 0.95
SkipNowMethod · 0.80
EncodeMethod · 0.80
ReplaceMethod · 0.80
ReadFileMethod · 0.65
fileFunction · 0.50
UnmarshalMethod · 0.45
StringMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected