-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Use service user for ci (#3228)
Use service user on CI - adjust config provider tests - limit the number of predefined profiles - create users with limited privileges to test different setups - extract toml builder (with follow-ups described in TODOs) - prepare user setups in TestClient (with follow-up improvements described in TODOs) Fixes: - fix the authenticator type merging (special empty value added) Misc: - bump sweepers timeout to 10m - left TODOs to check the behavior of 3-value booleans for each attribute in driver config - remove unused asserts - move some SDK client tests to testint package (TODO left for the rest)
- Loading branch information
1 parent
c209a8a
commit 2fb50d7
Showing
24 changed files
with
1,022 additions
and
509 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,162 @@ | ||
package helpers | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" | ||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
) | ||
|
||
// FullTomlConfigForServiceUser is a temporary function used to test provider configuration | ||
// TODO [SNOW-1827309]: use toml marshaling from "github.com/pelletier/go-toml/v2" | ||
// TODO [SNOW-1827309]: add builders for our toml config struct | ||
func FullTomlConfigForServiceUser(t *testing.T, profile string, userId sdk.AccountObjectIdentifier, roleId sdk.AccountObjectIdentifier, warehouseId sdk.AccountObjectIdentifier, accountIdentifier sdk.AccountIdentifier, privateKey string) string { | ||
t.Helper() | ||
|
||
return fmt.Sprintf(` | ||
[%[1]s] | ||
user = '%[2]s' | ||
privatekey = '''%[7]s''' | ||
role = '%[3]s' | ||
organizationname = '%[5]s' | ||
accountname = '%[6]s' | ||
warehouse = '%[4]s' | ||
clientip = '1.2.3.4' | ||
protocol = 'https' | ||
port = 443 | ||
oktaurl = 'https://example.com' | ||
clienttimeout = 10 | ||
jwtclienttimeout = 20 | ||
logintimeout = 30 | ||
requesttimeout = 40 | ||
jwtexpiretimeout = 50 | ||
externalbrowsertimeout = 60 | ||
maxretrycount = 1 | ||
authenticator = 'SNOWFLAKE_JWT' | ||
insecuremode = true | ||
ocspfailopen = true | ||
token = 'token' | ||
keepsessionalive = true | ||
disabletelemetry = true | ||
validatedefaultparameters = true | ||
clientrequestmfatoken = true | ||
clientstoretemporarycredential = true | ||
tracing = 'warning' | ||
tmpdirpath = '.' | ||
disablequerycontextcache = true | ||
includeretryreason = true | ||
disableconsolelogin = true | ||
[%[1]s.params] | ||
foo = 'bar' | ||
`, profile, userId.Name(), roleId.Name(), warehouseId.Name(), accountIdentifier.OrganizationName(), accountIdentifier.AccountName(), privateKey) | ||
} | ||
|
||
// FullInvalidTomlConfigForServiceUser is a temporary function used to test provider configuration | ||
func FullInvalidTomlConfigForServiceUser(t *testing.T, profile string) string { | ||
t.Helper() | ||
|
||
privateKey, _, _, _ := random.GenerateRSAKeyPair(t, "") | ||
return fmt.Sprintf(` | ||
[%[1]s] | ||
user = 'invalid' | ||
privatekey = '''%[2]s''' | ||
role = 'invalid' | ||
accountname = 'invalid' | ||
organizationname = 'invalid' | ||
warehouse = 'invalid' | ||
clientip = 'invalid' | ||
protocol = 'invalid' | ||
port = -1 | ||
oktaurl = 'invalid' | ||
clienttimeout = -1 | ||
jwtclienttimeout = -1 | ||
logintimeout = -1 | ||
requesttimeout = -1 | ||
jwtexpiretimeout = -1 | ||
externalbrowsertimeout = -1 | ||
maxretrycount = -1 | ||
authenticator = 'snowflake' | ||
insecuremode = true | ||
ocspfailopen = true | ||
token = 'token' | ||
keepsessionalive = true | ||
disabletelemetry = true | ||
validatedefaultparameters = false | ||
clientrequestmfatoken = true | ||
clientstoretemporarycredential = true | ||
tracing = 'invalid' | ||
tmpdirpath = '.' | ||
disablequerycontextcache = true | ||
includeretryreason = true | ||
disableconsolelogin = true | ||
[%[1]s.params] | ||
foo = 'bar'`, profile, privateKey) | ||
} | ||
|
||
// TomlConfigForServiceUser is a temporary function used to test provider configuration | ||
func TomlConfigForServiceUser(t *testing.T, profile string, userId sdk.AccountObjectIdentifier, roleId sdk.AccountObjectIdentifier, warehouseId sdk.AccountObjectIdentifier, accountIdentifier sdk.AccountIdentifier, privateKey string) string { | ||
t.Helper() | ||
|
||
return fmt.Sprintf(` | ||
[%[1]s] | ||
user = '%[2]s' | ||
privatekey = '''%[7]s''' | ||
role = '%[3]s' | ||
organizationname = '%[5]s' | ||
accountname = '%[6]s' | ||
warehouse = '%[4]s' | ||
authenticator = 'SNOWFLAKE_JWT' | ||
`, profile, userId.Name(), roleId.Name(), warehouseId.Name(), accountIdentifier.OrganizationName(), accountIdentifier.AccountName(), privateKey) | ||
} | ||
|
||
// TomlConfigForServiceUserWithEncryptedKey is a temporary function used to test provider configuration | ||
func TomlConfigForServiceUserWithEncryptedKey(t *testing.T, profile string, userId sdk.AccountObjectIdentifier, roleId sdk.AccountObjectIdentifier, warehouseId sdk.AccountObjectIdentifier, accountIdentifier sdk.AccountIdentifier, privateKey string, pass string) string { | ||
t.Helper() | ||
|
||
return fmt.Sprintf(` | ||
[%[1]s] | ||
user = '%[2]s' | ||
privatekey = '''%[7]s''' | ||
privatekeypassphrase = '%[8]s' | ||
role = '%[3]s' | ||
organizationname = '%[5]s' | ||
accountname = '%[6]s' | ||
warehouse = '%[4]s' | ||
authenticator = 'SNOWFLAKE_JWT' | ||
`, profile, userId.Name(), roleId.Name(), warehouseId.Name(), accountIdentifier.OrganizationName(), accountIdentifier.AccountName(), privateKey, pass) | ||
} | ||
|
||
// TomlIncorrectConfigForServiceUser is a temporary function used to test provider configuration | ||
func TomlIncorrectConfigForServiceUser(t *testing.T, profile string, accountIdentifier sdk.AccountIdentifier) string { | ||
t.Helper() | ||
|
||
privateKey, _, _, _ := random.GenerateRSAKeyPair(t, "") | ||
return fmt.Sprintf(` | ||
[%[1]s] | ||
user = 'non-existing-user' | ||
privatekey = '''%[4]s''' | ||
role = 'non-existing-role' | ||
organizationname = '%[2]s' | ||
accountname = '%[3]s' | ||
authenticator = 'SNOWFLAKE_JWT' | ||
`, profile, accountIdentifier.OrganizationName(), accountIdentifier.AccountName(), privateKey) | ||
} | ||
|
||
// TomlConfigForLegacyServiceUser is a temporary function used to test provider configuration | ||
func TomlConfigForLegacyServiceUser(t *testing.T, profile string, userId sdk.AccountObjectIdentifier, roleId sdk.AccountObjectIdentifier, warehouseId sdk.AccountObjectIdentifier, accountIdentifier sdk.AccountIdentifier, pass string) string { | ||
t.Helper() | ||
|
||
return fmt.Sprintf(` | ||
[%[1]s] | ||
user = '%[2]s' | ||
password = '%[7]s' | ||
role = '%[3]s' | ||
organizationname = '%[5]s' | ||
accountname = '%[6]s' | ||
warehouse = '%[4]s' | ||
authenticator = 'SNOWFLAKE' | ||
`, profile, userId.Name(), roleId.Name(), warehouseId.Name(), accountIdentifier.OrganizationName(), accountIdentifier.AccountName(), pass) | ||
} |
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
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
Oops, something went wrong.