-
Notifications
You must be signed in to change notification settings - Fork 427
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
chore: Use service user for ci #3228
Merged
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
374b51f
Adjust config hierarchy test
sfc-gh-asawicki 5f24aed
Progress with next tests
sfc-gh-asawicki 9bb2347
Progress with next tests part 2
sfc-gh-asawicki 27746eb
Remove unused asserts
sfc-gh-asawicki b49ef2d
Use tmp user for toml config test
sfc-gh-asawicki ec59063
Use tmp service user for env config test
sfc-gh-asawicki 158d13f
Use tmp service user for tfconfig test
sfc-gh-asawicki b5b3048
Use tmp service user for the config hierarchy test
sfc-gh-asawicki 4500654
Move user setup functions
sfc-gh-asawicki 44c6c35
Get rid of only account details profile
sfc-gh-asawicki e3d10d8
Simplify the test set up
sfc-gh-asawicki ba06037
Persist toml file as part of the setup
sfc-gh-asawicki ecb4ed8
Use tmp service user in tests (WIP)
sfc-gh-asawicki 68c9311
Use tmp service user in tests part 2
sfc-gh-asawicki 660822c
Test user+pass login
sfc-gh-asawicki 895c8e3
Test jwt login
sfc-gh-asawicki 3227e38
Get rid of unused profiles
sfc-gh-asawicki f27fa3a
Clean up tmp user setup helpers
sfc-gh-asawicki fccf25e
Extract empty auth type
sfc-gh-asawicki ddbcee9
Add issue numbers
sfc-gh-asawicki 816eaf9
Set config file temporarily
sfc-gh-asawicki 9111355
Run pre-push
sfc-gh-asawicki 7a59c2e
Uncomment assertions
sfc-gh-asawicki 1526af7
Fix tests
sfc-gh-asawicki 5253a50
Merge branch 'main' into use-service-user-for-ci
sfc-gh-asawicki 87ef844
Fix after review
sfc-gh-asawicki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
TODO: will be removed before merging