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

Function TestConvertYAML

coderd/externalauth/externalauth_test.go:1251–1354  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1249}
1250
1251func TestConvertYAML(t *testing.T) {
1252 t.Parallel()
1253
1254 instrument := promoauth.NewFactory(prometheus.NewRegistry())
1255 for _, tc := range []struct {
1256 Name string
1257 Input []codersdk.ExternalAuthConfig
1258 Output []*externalauth.Config
1259 Error string
1260 }{{
1261 Name: "InvalidID",
1262 Input: []codersdk.ExternalAuthConfig{{
1263 Type: string(codersdk.EnhancedExternalAuthProviderGitHub),
1264 ID: "$hi$",
1265 }},
1266 Error: "doesn't have a valid id",
1267 }, {
1268 Name: "NoClientID",
1269 Input: []codersdk.ExternalAuthConfig{{
1270 Type: string(codersdk.EnhancedExternalAuthProviderGitHub),
1271 }},
1272 Error: "client_id must be provided",
1273 }, {
1274 Name: "DuplicateType",
1275 Input: []codersdk.ExternalAuthConfig{{
1276 Type: string(codersdk.EnhancedExternalAuthProviderGitHub),
1277 ClientID: "example",
1278 ClientSecret: "example",
1279 }, {
1280 Type: string(codersdk.EnhancedExternalAuthProviderGitHub),
1281 ClientID: "example-2",
1282 ClientSecret: "example-2",
1283 }},
1284 Error: "multiple github external auth providers provided",
1285 }, {
1286 Name: "InvalidRegex",
1287 Input: []codersdk.ExternalAuthConfig{{
1288 Type: string(codersdk.EnhancedExternalAuthProviderGitHub),
1289 ClientID: "example",
1290 ClientSecret: "example",
1291 Regex: `\K`,
1292 }},
1293 Error: "compile regex for external auth provider",
1294 }, {
1295 Name: "NoDeviceURL",
1296 Input: []codersdk.ExternalAuthConfig{{
1297 Type: string(codersdk.EnhancedExternalAuthProviderGitLab),
1298 ClientID: "example",
1299 ClientSecret: "example",
1300 DeviceFlow: true,
1301 }},
1302 Error: "device auth url must be provided",
1303 }} {
1304 t.Run(tc.Name, func(t *testing.T) {
1305 t.Parallel()
1306 output, err := externalauth.ConvertConfig(instrument, tc.Input, &url.URL{})
1307 if tc.Error != "" {
1308 require.Error(t, err)

Callers

nothing calls this directly

Calls 8

NewFactoryFunction · 0.92
ConvertConfigFunction · 0.92
RunMethod · 0.65
AuthCodeURLMethod · 0.65
ErrorMethod · 0.45
ContainsMethod · 0.45
EqualMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected