-
Notifications
You must be signed in to change notification settings - Fork 554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Okta, TOTP and PingID MFA methods #1395
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. I've completed the first pass. Added some suggestions/comments etc.
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testutil.TestEntPreCheck(t) }, | ||
Providers: testProviders, | ||
Steps: []resource.TestStep{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should add an import step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added import step in 5d506d7
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testutil.TestEntPreCheck(t) }, | ||
Providers: testProviders, | ||
Steps: []resource.TestStep{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should add an import step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added import step in 5d506d7
vault/resource_mfa_okta.go
Outdated
func mfaOktaRequestData(d *schema.ResourceData) map[string]interface{} { | ||
data := map[string]interface{}{} | ||
|
||
nonBooleanAPIFields := []string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it's okay just name this variable fields
like you have in other functions, and to move it relative to its usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5d506d7
vault/resource_mfa_okta.go
Outdated
"mount_accessor": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The mount to tie this method to for use in automatic mappings. The mapping will use the Name field of Aliases associated with this mount as the username in the mapping.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: fold long lines whenever possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5d506d7
vault/resource_mfa_totp_test.go
Outdated
) | ||
|
||
func TestMFATOTPBasic(t *testing.T) { | ||
mfaTOTPPath := acctest.RandomWithPrefix("mfa-totp") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shadow declaration of mfaTOTPPath()
.
It's preferable to use generic variable names in this scope.
mfaTOTPPath := acctest.RandomWithPrefix("mfa-totp") | |
path := acctest.RandomWithPrefix("mfa-totp") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5d506d7
vault/resource_mfa_totp_test.go
Outdated
return fmt.Sprintf(` | ||
resource "vault_mfa_totp" "test" { | ||
name = %q | ||
issuer = "hashicorp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issuer = "hashicorp" | |
issuer = "hashicorp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5d506d7
vault/resource_mfa_totp_test.go
Outdated
issuer = "hashicorp" | ||
period = 60 | ||
algorithm = "SHA256" | ||
digits = 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mix of spaces and hard tabs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5d506d7
return data | ||
} | ||
|
||
func mfaOktaWrite(d *schema.ResourceData, meta interface{}) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are using this function for both create and update, would it make sense to give it a more explicit name e.g. mfaOktaCreateOrUpdate()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Ship it!
Adds three new resources to support Okta, TOTP and PingID
sys/mfa
methods.Output from acceptance testing: