-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathauth_with_okta_test.go
52 lines (40 loc) · 1.53 KB
/
auth_with_okta_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package gosnowflake
import (
"errors"
"fmt"
"net/url"
"testing"
)
func TestOktaSuccessful(t *testing.T) {
cfg := setupOktaTest(t)
err := verifyConnectionToSnowflakeAuthTests(t, cfg)
assertNilE(t, err, fmt.Sprintf("failed to connect. err: %v", err))
}
func TestOktaWrongCredentials(t *testing.T) {
cfg := setupOktaTest(t)
cfg.Password = "fakePassword"
err := verifyConnectionToSnowflakeAuthTests(t, cfg)
var snowflakeErr *SnowflakeError
assertTrueF(t, errors.As(err, &snowflakeErr))
assertEqualE(t, snowflakeErr.Number, 261006, fmt.Sprintf("Expected 261006, but got %v", snowflakeErr.Number))
}
func TestOktaWrongAuthenticator(t *testing.T) {
cfg := setupOktaTest(t)
invalidAddress, err := url.Parse("https://fake-account-0000.okta.com")
assertNilF(t, err, fmt.Sprintf("failed to parse: %v", err))
cfg.OktaURL = invalidAddress
err = verifyConnectionToSnowflakeAuthTests(t, cfg)
var snowflakeErr *SnowflakeError
assertTrueF(t, errors.As(err, &snowflakeErr))
assertEqualE(t, snowflakeErr.Number, 390139, fmt.Sprintf("Expected 390139, but got %v", snowflakeErr.Number))
}
func setupOktaTest(t *testing.T) *Config {
runOnlyOnDockerContainer(t, "Running only on Docker container")
urlEnv, err := GetFromEnv("SNOWFLAKE_AUTH_TEST_OKTA_AUTH", true)
assertNilF(t, err, fmt.Sprintf("failed to get env: %v", err))
cfg, err := getAuthTestsConfig(t, AuthTypeOkta)
assertNilF(t, err, fmt.Sprintf("failed to get config: %v", err))
cfg.OktaURL, err = url.Parse(urlEnv)
assertNilF(t, err, fmt.Sprintf("failed to parse: %v", err))
return cfg
}