func TestOIDCRoleMapping(t *testing.T) {
	// create a connector
	oidcConnector := NewOIDCConnector("example", OIDCConnectorSpecV2{
		IssuerURL:    "https://www.exmaple.com",
		ClientID:     "example-client-id",
		ClientSecret: "example-client-secret",
		RedirectURL:  "https://localhost:3080/v1/webapi/oidc/callback",
		Display:      "sign in with example.com",
		Scope:        []string{"foo", "bar"},
		ClaimsToRoles: []ClaimMapping{
			{
				Claim: "roles",
				Value: "teleport-user",
				Roles: []string{"user"},
			},
		},
	})

	// create some claims
	var claims = make(jose.Claims)
	claims.Add("roles", "teleport-user")
	claims.Add("email", "foo@example.com")
	claims.Add("nickname", "foo")
	claims.Add("full_name", "foo bar")

	traits := OIDCClaimsToTraits(claims)
	require.Len(t, traits, 4)

	roles := TraitsToRoles(oidcConnector.GetTraitMappings(), traits)
	require.Len(t, roles, 1)
	require.Equal(t, "user", roles[0])
}
// TestOIDCRoleMapping verifies basic mapping from OIDC claims to roles.
TestOIDCRoleMapping verifies basic mapping from OIDC claims to roles.
// TestOIDCRoleMapping verifies basic mapping from OIDC claims to roles .
func TestOIDCRoleMapping(t *testing.T) {
	oidcConnector := NewOIDCConnector("example", OIDCConnectorSpecV2{
		IssuerURL:    "https://www.exmaple.com",
		ClientID:     "example-client-id",
		ClientSecret: "example-client-secret",
		RedirectURL:  "https://localhost:3080/v1/webapi/oidc/callback",
		Display:      "sign in with example.com",
		Scope:        []string{"foo", "bar"},
		ClaimsToRoles: []ClaimMapping{
			{
				Claim: "roles",
				Value: "teleport-user",
				Roles: []string{"user"},
			},
		},
	})
	var claims = make(jose.Claims)
	claims.Add("roles", "teleport-user")
	claims.Add("email", "foo@example.com")
	claims.Add("nickname", "foo")
	claims.Add("full_name", "foo bar")
	traits := OIDCClaimsToTraits(claims)
	require.Len(t, traits, 4)
	roles := TraitsToRoles(oidcConnector.GetTraitMappings(), traits)
	require.Len(t, roles, 1)
	require.Equal(t, "user", roles[0])
}
func TestOIDCRoleMapping ( t * testing . T ) { oidcConnector := NewOIDCConnector ( " " , OIDCConnectorSpecV2 { IssuerURL : " " , ClientID : " " , ClientSecret : " " , RedirectURL : " " , Display : " " , Scope : [ ] string { " " , " " } , ClaimsToRoles : [ ] ClaimMapping { { Claim : " " , Value : " " , Roles : [ ] string { " " } , } , } , } ) var claims = make ( jose . Claims ) claims . Add ( " " , " " ) claims . Add ( " " , " " ) claims . Add ( " " , " " ) claims . Add ( " " , " " ) traits := OIDCClaimsToTraits ( claims ) require . Len ( t , traits , 4 ) roles := TraitsToRoles ( oidcConnector . GetTraitMappings ( ) , traits ) require . Len ( t , roles , 1 ) require . Equal ( t , " " , roles [ 0 ] ) }
TestOIDCRoleMapping verifies basic mapping from OIDC claims to roles.
TestOIDCRoleMapping verifies basic mapping from OIDC claims to roles .
// create a connector // create some claims