Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Support for Facebook connection provider config #221

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions auth0/resource_auth0_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,45 @@ resource "auth0_connection" "google_oauth2" {
}
`

func TestAccConnectionFacebook(t *testing.T) {

rand := random.String(6)

resource.Test(t, resource.TestCase{
Providers: map[string]terraform.ResourceProvider{
"auth0": Provider(),
},
Steps: []resource.TestStep{
{
Config: random.Template(testAccConnectionFacebookConfig, rand),
Check: resource.ComposeTestCheckFunc(
random.TestCheckResourceAttr("auth0_connection.facebook", "name", "Acceptance-Test-Facebook-{{.random}}", rand),
resource.TestCheckResourceAttr("auth0_connection.facebook", "strategy", "facebook"),
resource.TestCheckResourceAttr("auth0_connection.facebook", "options.0.client_id", ""),
resource.TestCheckResourceAttr("auth0_connection.facebook", "options.0.client_secret", ""),
resource.TestCheckResourceAttr("auth0_connection.facebook", "options.0.scopes.#", "4"),
resource.TestCheckResourceAttr("auth0_connection.facebook", "options.0.scopes.3590537325", "public_profile"),
resource.TestCheckResourceAttr("auth0_connection.facebook", "options.0.scopes.881205744", "email"),
),
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add another step so we can test the update operation?

},
})
}

const testAccConnectionFacebookConfig = `

resource "auth0_connection" "facebook" {
name = "Acceptance-Test-Facebook-{{.random}}"
is_domain_connection = false
strategy = "facebook"
options {
client_id = ""
client_secret = ""
scopes = [ "public_profile", "email", "groups_access_member_info", "user_birthday" ]
}
}
`

func TestAccConnectionGitHub(t *testing.T) {

rand := random.String(6)
Expand Down
27 changes: 24 additions & 3 deletions auth0/structure_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func flattenConnectionOptions(d Data, options interface{}) []interface{} {
m = flattenConnectionOptionsAuth0(d, o)
case *management.ConnectionOptionsGoogleOAuth2:
m = flattenConnectionOptionsGoogleOAuth2(o)
// case *management.ConnectionOptionsFacebook:
// m = flattenConnectionOptionsFacebook(o)
case *management.ConnectionOptionsFacebook:
m = flattenConnectionOptionsFacebook(o)
// case *management.ConnectionOptionsApple:
// m = flattenConnectionOptionsApple(o)
// case *management.ConnectionOptionsLinkedin:
Expand Down Expand Up @@ -79,6 +79,14 @@ func flattenConnectionOptionsGoogleOAuth2(o *management.ConnectionOptionsGoogleO
}
}

func flattenConnectionOptionsFacebook(o *management.ConnectionOptionsFacebook) interface{} {
return map[string]interface{}{
"client_id": o.GetClientID(),
"client_secret": o.GetClientSecret(),
"scopes": o.Scopes(),
}
}

func flattenConnectionOptionsSalesforce(o *management.ConnectionOptionsSalesforce) interface{} {
return map[string]interface{}{
"client_id": o.GetClientID(),
Expand Down Expand Up @@ -172,7 +180,8 @@ func expandConnection(d Data) *management.Connection {
c.Options = expandConnectionOptionsAuth0(d)
case management.ConnectionStrategyGoogleOAuth2:
c.Options = expandConnectionOptionsGoogleOAuth2(d)
// case management.ConnectionStrategyFacebook
case management.ConnectionStrategyFacebook:
c.Options = expandConnectionOptionsFacebook(d)
// management.ConnectionStrategyApple
// management.ConnectionStrategyLinkedin
case management.ConnectionStrategyGitHub:
Expand Down Expand Up @@ -266,6 +275,18 @@ func expandConnectionOptionsGoogleOAuth2(d Data) *management.ConnectionOptionsGo
return o
}

func expandConnectionOptionsFacebook(d Data) *management.ConnectionOptionsFacebook {

o := &management.ConnectionOptionsFacebook{
ClientID: String(d, "client_id"),
ClientSecret: String(d, "client_secret"),
}

expandConnectionOptionsScopes(d, o)

return o
}

func expandConnectionOptionsSalesforce(d Data) *management.ConnectionOptionsSalesforce {

o := &management.ConnectionOptionsSalesforce{
Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/connection.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ Arguments accepted by this resource include:
* `custom_scripts` - (Optional) Map(String).
* `configuration` - (Optional) Map(String), Case-sensitive.

**Facebook**

* `client_id` - (Optional) String. Corresponds to the Facebook application ID.
* `client_secret` - (Optional) String, Case-sensitive. The Facebook application client secret.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome ;)

**Azure AD Options**

* `app_id` - (Optional) String
Expand Down