-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setting default
idle_session_lifetime
on tenant import (#849)
* Using default value for tenant idle_session_lifetime * Abstracting-out defaults into their global values * Requested changes --------- Co-authored-by: Will Vedder <will.vedder@okta.com>
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package tenant | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/auth0/go-auth0" | ||
"github.com/auth0/go-auth0/management" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFlattenTenant(t *testing.T) { | ||
mockResourceData := schema.TestResourceDataRaw(t, NewResource().Schema, map[string]interface{}{}) | ||
|
||
t.Run("it sets default values if remote tenant does not have them set", func(t *testing.T) { | ||
tenant := management.Tenant{ | ||
IdleSessionLifetime: nil, | ||
SessionLifetime: nil, | ||
} | ||
|
||
err := flattenTenant(mockResourceData, &tenant) | ||
|
||
assert.NoError(t, err) | ||
assert.Equal(t, mockResourceData.Get("idle_session_lifetime"), 72.00) | ||
assert.Equal(t, mockResourceData.Get("session_lifetime"), 168.00) | ||
}) | ||
|
||
t.Run("it does not set default values if remote tenant has values set", func(t *testing.T) { | ||
tenant := management.Tenant{ | ||
IdleSessionLifetime: auth0.Float64(73.5), | ||
SessionLifetime: auth0.Float64(169.5), | ||
} | ||
|
||
err := flattenTenant(mockResourceData, &tenant) | ||
|
||
assert.NoError(t, err) | ||
assert.Equal(t, mockResourceData.Get("idle_session_lifetime"), 73.5) | ||
assert.Equal(t, mockResourceData.Get("session_lifetime"), 169.5) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters