Skip to content

Commit

Permalink
Fix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-asawicki committed Nov 28, 2024
1 parent 5253a50 commit 87ef844
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
44 changes: 27 additions & 17 deletions pkg/acceptance/helpers/grant_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,17 @@ func (c *GrantClient) GrantPrivilegesOnDatabaseToAccountRole(
withGrantOption bool,
) {
t.Helper()
ctx := context.Background()

err := c.client().GrantPrivilegesToAccountRole(
ctx,
&sdk.AccountRoleGrantPrivileges{
AccountObjectPrivileges: privileges,
},
c.grantPrivilegesOnAccountLevelObjectToAccountRole(
t,
accountRoleId,
&sdk.AccountRoleGrantOn{
AccountObject: &sdk.GrantOnAccountObject{
Database: sdk.Pointer(databaseId),
},
},
accountRoleId,
&sdk.GrantPrivilegesToAccountRoleOptions{
WithGrantOption: sdk.Bool(withGrantOption),
},
privileges,
withGrantOption,
)
require.NoError(t, err)
}

func (c *GrantClient) GrantPrivilegesOnWarehouseToAccountRole(
Expand All @@ -163,6 +156,27 @@ func (c *GrantClient) GrantPrivilegesOnWarehouseToAccountRole(
warehouseId sdk.AccountObjectIdentifier,
privileges []sdk.AccountObjectPrivilege,
withGrantOption bool,
) {
t.Helper()
c.grantPrivilegesOnAccountLevelObjectToAccountRole(
t,
accountRoleId,
&sdk.AccountRoleGrantOn{
AccountObject: &sdk.GrantOnAccountObject{
Warehouse: sdk.Pointer(warehouseId),
},
},
privileges,
withGrantOption,
)
}

func (c *GrantClient) grantPrivilegesOnAccountLevelObjectToAccountRole(
t *testing.T,
accountRoleId sdk.AccountObjectIdentifier,
accountObjectGrantOn *sdk.AccountRoleGrantOn,
privileges []sdk.AccountObjectPrivilege,
withGrantOption bool,
) {
t.Helper()
ctx := context.Background()
Expand All @@ -172,11 +186,7 @@ func (c *GrantClient) GrantPrivilegesOnWarehouseToAccountRole(
&sdk.AccountRoleGrantPrivileges{
AccountObjectPrivileges: privileges,
},
&sdk.AccountRoleGrantOn{
AccountObject: &sdk.GrantOnAccountObject{
Warehouse: sdk.Pointer(warehouseId),
},
},
accountObjectGrantOn,
accountRoleId,
&sdk.GrantPrivilegesToAccountRoleOptions{
WithGrantOption: sdk.Bool(withGrantOption),
Expand Down
7 changes: 3 additions & 4 deletions pkg/manual_tests/authentication_methods/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/manualtestprofiles"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testprofiles"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/snowflakeenvs"
Expand All @@ -32,7 +31,7 @@ func TestAcc_Provider_OktaAuth(t *testing.T) {
},
Steps: []resource.TestStep{
{
Config: providerConfigWithAuthenticator(manualtestprofiles.Okta, sdk.AuthenticationTypeOkta),
Config: providerConfigWithAuthenticator(Okta, sdk.AuthenticationTypeOkta),
},
},
})
Expand Down Expand Up @@ -76,11 +75,11 @@ func TestAcc_Provider_UsernamePasswordMfaAuthWithPasscode(t *testing.T) {
Steps: []resource.TestStep{
// ensure MFA is checked here - accept access to keychain on your device
{
Config: providerConfigWithAuthenticator(manualtestprofiles.DefaultWithPasscode, sdk.AuthenticationTypeUsernamePasswordMfa),
Config: providerConfigWithAuthenticator(DefaultWithPasscode, sdk.AuthenticationTypeUsernamePasswordMfa),
},
// check that MFA login is cached - this step should not require manual action
{
Config: providerConfigWithAuthenticator(manualtestprofiles.DefaultWithPasscode, sdk.AuthenticationTypeUsernamePasswordMfa),
Config: providerConfigWithAuthenticator(DefaultWithPasscode, sdk.AuthenticationTypeUsernamePasswordMfa),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package manualtestprofiles
package manual

const (
DefaultWithPasscode = "default_with_passcode"
Expand Down
3 changes: 1 addition & 2 deletions pkg/provider/provider_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,7 @@ func TestAcc_Provider_invalidConfigurations(t *testing.T) {
ExpectError: regexp.MustCompile(`invalid driver log level: invalid`),
},
{
Config: providerConfig("non-existing"),
// .* is used to match the error message regarding of the home user location
Config: providerConfig("non-existing"),
ExpectError: regexp.MustCompile(fmt.Sprintf(`profile "non-existing" not found in file %s`, tmpServiceUserConfig.Path)),
},
},
Expand Down

0 comments on commit 87ef844

Please sign in to comment.