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

Commit

Permalink
Merge branch 'linkedin-connection-provider-support' of ssh://github.c…
Browse files Browse the repository at this point in the history
…om/relu/terraform-provider-auth0 into relu-linkedin-connection-provider-support
  • Loading branch information
alexkappa committed May 7, 2020
2 parents ca0bc1b + 81b5ee1 commit b86ac0c
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 6 deletions.
2 changes: 1 addition & 1 deletion auth0/resource_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func newConnection() *schema.Resource {
},

"strategy_version": {
Type: schema.TypeString,
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
Expand Down
66 changes: 65 additions & 1 deletion auth0/resource_auth0_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ resource "auth0_connection" "facebook" {
`

func TestAccConnectionApple(t *testing.T) {

rand := random.String(6)

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -661,6 +660,71 @@ resource "auth0_connection" "apple" {
}
`

func TestAccConnectionLinkedin(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(testAccConnectionLinkedinConfig, rand),
Check: resource.ComposeTestCheckFunc(
random.TestCheckResourceAttr("auth0_connection.linkedin", "name", "Acceptance-Test-Linkedin-{{.random}}", rand),
resource.TestCheckResourceAttr("auth0_connection.linkedin", "strategy", "linkedin"),
resource.TestCheckResourceAttr("auth0_connection.linkedin", "options.0.client_id", "client_id"),
resource.TestCheckResourceAttr("auth0_connection.linkedin", "options.0.client_secret", "client_secret"),
resource.TestCheckResourceAttr("auth0_connection.linkedin", "options.0.strategy_version", "2"),
resource.TestCheckResourceAttr("auth0_connection.linkedin", "options.0.scopes.#", "3"),
resource.TestCheckResourceAttr("auth0_connection.linkedin", "options.0.scopes.370042894", "basic_profile"),
resource.TestCheckResourceAttr("auth0_connection.linkedin", "options.0.scopes.881205744", "email"),
),
},
{
Config: random.Template(testAccConnectionLinkedinConfigUpdate, rand),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("auth0_connection.linkedin", "options.0.client_id", "client_id_update"),
resource.TestCheckResourceAttr("auth0_connection.linkedin", "options.0.client_secret", "client_secret_update"),
resource.TestCheckResourceAttr("auth0_connection.linkedin", "options.0.scopes.370042894", "basic_profile"),
resource.TestCheckResourceAttr("auth0_connection.linkedin", "options.0.scopes.#", "2"),
),
},
},
})
}

const testAccConnectionLinkedinConfig = `
resource "auth0_connection" "linkedin" {
name = "Acceptance-Test-Linkedin-{{.random}}"
is_domain_connection = false
strategy = "linkedin"
options {
client_id = "client_id"
client_secret = "client_secret"
strategy_version = 2
scopes = [ "basic_profile", "profile", "email" ]
}
}
`

const testAccConnectionLinkedinConfigUpdate = `
resource "auth0_connection" "linkedin" {
name = "Acceptance-Test-Linkedin-{{.random}}"
is_domain_connection = false
strategy = "linkedin"
options {
client_id = "client_id_update"
client_secret = "client_secret_update"
strategy_version = 2
scopes = [ "basic_profile", "profile" ]
}
}
`

func TestAccConnectionGitHub(t *testing.T) {

rand := random.String(6)
Expand Down
29 changes: 26 additions & 3 deletions auth0/structure_auth0_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func flattenConnectionOptions(d Data, options interface{}) []interface{} {
m = flattenConnectionOptionsFacebook(o)
case *management.ConnectionOptionsApple:
m = flattenConnectionOptionsApple(o)
// case *management.ConnectionOptionsLinkedin:
// m = flattenConnectionOptionsLinkedin(o)
case *management.ConnectionOptionsLinkedin:
m = flattenConnectionOptionsLinkedin(o)
case *management.ConnectionOptionsGitHub:
m = flattenConnectionOptionsGitHub(o)
// case *management.ConnectionOptionsWindowsLive:
Expand Down Expand Up @@ -97,6 +97,15 @@ func flattenConnectionOptionsApple(o *management.ConnectionOptionsApple) interfa
}
}

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

func flattenConnectionOptionsSalesforce(o *management.ConnectionOptionsSalesforce) interface{} {
return map[string]interface{}{
"client_id": o.GetClientID(),
Expand Down Expand Up @@ -194,7 +203,8 @@ func expandConnection(d Data) *management.Connection {
c.Options = expandConnectionOptionsFacebook(d)
case management.ConnectionStrategyApple:
c.Options = expandConnectionOptionsApple(d)
// management.ConnectionStrategyLinkedin
case management.ConnectionStrategyLinkedin:
c.Options = expandConnectionOptionsLinkedin(d)
case management.ConnectionStrategyGitHub:
c.Options = expandConnectionOptionsGitHub(d)
// management.ConnectionStrategyWindowsLive:
Expand Down Expand Up @@ -312,6 +322,19 @@ func expandConnectionOptionsApple(d Data) *management.ConnectionOptionsApple {
return o
}

func expandConnectionOptionsLinkedin(d Data) *management.ConnectionOptionsLinkedin {

o := &management.ConnectionOptionsLinkedin{
ClientID: String(d, "client_id"),
ClientSecret: String(d, "client_secret"),
StrategyVersion: Int(d, "strategy_version"),
}

expandConnectionOptionsScopes(d, o)

return o
}

func expandConnectionOptionsSalesforce(d Data) *management.ConnectionOptionsSalesforce {

o := &management.ConnectionOptionsSalesforce{
Expand Down
8 changes: 7 additions & 1 deletion website/docs/r/connection.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Arguments accepted by this resource include:
* `validation` - (Optional) String.
* `password_policy` - (Optional) String. Indicates level of password strength to enforce during authentication. A strong password policy will make it difficult, if not improbable, for someone to guess a password through either manual or automated means. Options include `none`, `low`, `fair`, `good`, `excellent`.
* `password_history` - (Optional) List(Resource). Configuration settings for the password history that is maintained for each user to prevent the reuse of passwords. For details, see [Password History](#password-history).
* `password_no_personal_info` - (Optional) List(Resource). Configuration settings for the password personal info check, which does not allow passwords that contain any part of the user's personal data, including user's name, username, nickname, user_metadata.name, user_metadata.first, user_metadata.last, user's email, or firstpart of the user's email. For details, see [Password No Personal Info](#password-no-personal-info).
* `password_no_personal_info` - (Optional) List(Resource). Configuration settings for the password personal info check, which does not allow passwords that contain any part of the user's personal data, including user's name, username, nickname, user_metadata.name, user_metadata.first, user_metadata.last, user's email, or first part of the user's email. For details, see [Password No Personal Info](#password-no-personal-info).
* `password_dictionary` - (Optional) List(Resource). Configuration settings for the password dictionary check, which does not allow passwords that are part of the password dictionary. For details, see [Password Dictionary](#password-dictionary).
* `password_complexity_options` - (Optional) List(Resource). Configuration settings for password complexity. For details, see [Password Complexity Options](#password-complexity-options).
* `api_enable_users` - (Optional) Boolean.
Expand All @@ -107,6 +107,12 @@ Arguments accepted by this resource include:
* `client_id` - (Optional) String. Corresponds to the Facebook application ID.
* `client_secret` - (Optional) String, Case-sensitive. The Facebook application client secret.

**Linkedin**

* `client_id` - (Optional) String. Linkedin API Key.
* `client_secret` - (Optional) String. Case-sensitive. Linkedin secret key.
* `strategy_version` - (Optional) Int. Version 1 is deprecated, use version 2.

**Azure AD Options**

* `app_id` - (Optional) String
Expand Down

0 comments on commit b86ac0c

Please sign in to comment.