@@ -358,6 +358,86 @@ resource "auth0_connection" "oidc" {
358358}
359359`
360360
361+ func TestAccConnectionOAuth2 (t * testing.T ) {
362+
363+ rand := random .String (6 )
364+
365+ resource .Test (t , resource.TestCase {
366+ Providers : map [string ]terraform.ResourceProvider {
367+ "auth0" : Provider (),
368+ },
369+ Steps : []resource.TestStep {
370+ {
371+ Config : random .Template (testAccConnectionOAuth2Config , rand ),
372+ Check : resource .ComposeTestCheckFunc (
373+ random .TestCheckResourceAttr ("auth0_connection.oauth2" , "name" , "Acceptance-Test-OAuth2-{{.random}}" , rand ),
374+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "strategy" , "oauth2" ),
375+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.client_id" , "123456" ),
376+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.client_secret" , "123456" ),
377+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.token_endpoint" , "https://api.login.yahoo.com/oauth2/get_token" ),
378+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.authorization_endpoint" , "https://api.login.yahoo.com/oauth2/request_auth" ),
379+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.scopes.#" , "3" ),
380+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.scopes.2517049750" , "openid" ),
381+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.scopes.4080487570" , "profile" ),
382+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.scopes.881205744" , "email" ),
383+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.scripts.fetchUserProfile" , "function( { return callback(null) }" ),
384+ ),
385+ },
386+ {
387+ Config : random .Template (testAccConnectionOAuth2ConfigUpdate , rand ),
388+ Check : resource .ComposeTestCheckFunc (
389+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.client_id" , "1234567" ),
390+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.client_secret" , "1234567" ),
391+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.token_endpoint" , "https://api.paypal.com/v1/oauth2/token" ),
392+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.authorization_endpoint" , "https://www.paypal.com/signin/authorize" ),
393+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.scopes.#" , "2" ),
394+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.scopes.2517049750" , "openid" ),
395+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.scopes.881205744" , "email" ),
396+ resource .TestCheckResourceAttr ("auth0_connection.oauth2" , "options.0.scripts.fetchUserProfile" , "function( { return callback(null) }" ),
397+ ),
398+ },
399+ },
400+ })
401+ }
402+
403+ const testAccConnectionOAuth2Config = `
404+
405+ resource "auth0_connection" "oauth2" {
406+ name = "Acceptance-Test-OAuth2-{{.random}}"
407+ strategy = "oauth2"
408+ is_domain_connection = false
409+ options {
410+ client_id = "123456"
411+ client_secret = "123456"
412+ token_endpoint = "https://api.login.yahoo.com/oauth2/get_token"
413+ authorization_endpoint = "https://api.login.yahoo.com/oauth2/request_auth"
414+ scopes = [ "openid", "email", "profile" ]
415+ scripts = {
416+ fetchUserProfile= "function( { return callback(null) }"
417+ }
418+ }
419+ }
420+ `
421+
422+ const testAccConnectionOAuth2ConfigUpdate = `
423+
424+ resource "auth0_connection" "oauth2" {
425+ name = "Acceptance-Test-OAuth2-{{.random}}"
426+ strategy = "oauth2"
427+ is_domain_connection = false
428+ options {
429+ client_id = "1234567"
430+ client_secret = "1234567"
431+ token_endpoint = "https://api.paypal.com/v1/oauth2/token"
432+ authorization_endpoint = "https://www.paypal.com/signin/authorize"
433+ scopes = [ "openid", "email" ]
434+ scripts = {
435+ fetchUserProfile= "function( { return callback(null) }"
436+ }
437+ }
438+ }
439+ `
440+
361441func TestAccConnectionWithEnbledClients (t * testing.T ) {
362442
363443 rand := random .String (6 )
0 commit comments