diff options
author | Jake Champlin <jake@gnu.space> | 2017-06-09 17:54:32 +0000 |
---|---|---|
committer | Jake Champlin <jake@gnu.space> | 2017-06-09 17:54:32 +0000 |
commit | 9b12e4fe6f3c95986f1f3ec791636c58ca7e7583 (patch) | |
tree | 38f5f12bec0e488a12f0459a7356e6b7de7d8f84 /vendor/github.com/hashicorp/terraform/helper/acctest | |
parent | cec3de8a3bcaffd21dedd1bf42da4b490cae7e16 (diff) | |
download | terraform-provider-statuscake-9b12e4fe6f3c95986f1f3ec791636c58ca7e7583.tar.gz terraform-provider-statuscake-9b12e4fe6f3c95986f1f3ec791636c58ca7e7583.tar.zst terraform-provider-statuscake-9b12e4fe6f3c95986f1f3ec791636c58ca7e7583.zip |
Transfer of provider code
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/helper/acctest')
3 files changed, 0 insertions, 122 deletions
diff --git a/vendor/github.com/hashicorp/terraform/helper/acctest/acctest.go b/vendor/github.com/hashicorp/terraform/helper/acctest/acctest.go deleted file mode 100644 index 9d31031..0000000 --- a/vendor/github.com/hashicorp/terraform/helper/acctest/acctest.go +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | // Package acctest contains for Terraform Acceptance Tests | ||
2 | package acctest | ||
diff --git a/vendor/github.com/hashicorp/terraform/helper/acctest/random.go b/vendor/github.com/hashicorp/terraform/helper/acctest/random.go deleted file mode 100644 index 3ddc078..0000000 --- a/vendor/github.com/hashicorp/terraform/helper/acctest/random.go +++ /dev/null | |||
@@ -1,93 +0,0 @@ | |||
1 | package acctest | ||
2 | |||
3 | import ( | ||
4 | "bufio" | ||
5 | "bytes" | ||
6 | crand "crypto/rand" | ||
7 | "crypto/rsa" | ||
8 | "crypto/x509" | ||
9 | "encoding/pem" | ||
10 | "fmt" | ||
11 | "math/rand" | ||
12 | "strings" | ||
13 | "time" | ||
14 | |||
15 | "golang.org/x/crypto/ssh" | ||
16 | ) | ||
17 | |||
18 | // Helpers for generating random tidbits for use in identifiers to prevent | ||
19 | // collisions in acceptance tests. | ||
20 | |||
21 | // RandInt generates a random integer | ||
22 | func RandInt() int { | ||
23 | reseed() | ||
24 | return rand.New(rand.NewSource(time.Now().UnixNano())).Int() | ||
25 | } | ||
26 | |||
27 | // RandomWithPrefix is used to generate a unique name with a prefix, for | ||
28 | // randomizing names in acceptance tests | ||
29 | func RandomWithPrefix(name string) string { | ||
30 | reseed() | ||
31 | return fmt.Sprintf("%s-%d", name, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) | ||
32 | } | ||
33 | |||
34 | func RandIntRange(min int, max int) int { | ||
35 | reseed() | ||
36 | source := rand.New(rand.NewSource(time.Now().UnixNano())) | ||
37 | rangeMax := max - min | ||
38 | |||
39 | return int(source.Int31n(int32(rangeMax))) | ||
40 | } | ||
41 | |||
42 | // RandString generates a random alphanumeric string of the length specified | ||
43 | func RandString(strlen int) string { | ||
44 | return RandStringFromCharSet(strlen, CharSetAlphaNum) | ||
45 | } | ||
46 | |||
47 | // RandStringFromCharSet generates a random string by selecting characters from | ||
48 | // the charset provided | ||
49 | func RandStringFromCharSet(strlen int, charSet string) string { | ||
50 | reseed() | ||
51 | result := make([]byte, strlen) | ||
52 | for i := 0; i < strlen; i++ { | ||
53 | result[i] = charSet[rand.Intn(len(charSet))] | ||
54 | } | ||
55 | return string(result) | ||
56 | } | ||
57 | |||
58 | // RandSSHKeyPair generates a public and private SSH key pair. The public key is | ||
59 | // returned in OpenSSH format, and the private key is PEM encoded. | ||
60 | func RandSSHKeyPair(comment string) (string, string, error) { | ||
61 | privateKey, err := rsa.GenerateKey(crand.Reader, 1024) | ||
62 | if err != nil { | ||
63 | return "", "", err | ||
64 | } | ||
65 | |||
66 | var privateKeyBuffer bytes.Buffer | ||
67 | privateKeyPEM := &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(privateKey)} | ||
68 | if err := pem.Encode(bufio.NewWriter(&privateKeyBuffer), privateKeyPEM); err != nil { | ||
69 | return "", "", err | ||
70 | } | ||
71 | |||
72 | publicKey, err := ssh.NewPublicKey(&privateKey.PublicKey) | ||
73 | if err != nil { | ||
74 | return "", "", err | ||
75 | } | ||
76 | keyMaterial := strings.TrimSpace(string(ssh.MarshalAuthorizedKey(publicKey))) | ||
77 | return fmt.Sprintf("%s %s", keyMaterial, comment), privateKeyBuffer.String(), nil | ||
78 | } | ||
79 | |||
80 | // Seeds random with current timestamp | ||
81 | func reseed() { | ||
82 | rand.Seed(time.Now().UTC().UnixNano()) | ||
83 | } | ||
84 | |||
85 | const ( | ||
86 | // CharSetAlphaNum is the alphanumeric character set for use with | ||
87 | // RandStringFromCharSet | ||
88 | CharSetAlphaNum = "abcdefghijklmnopqrstuvwxyz012346789" | ||
89 | |||
90 | // CharSetAlpha is the alphabetical character set for use with | ||
91 | // RandStringFromCharSet | ||
92 | CharSetAlpha = "abcdefghijklmnopqrstuvwxyz" | ||
93 | ) | ||
diff --git a/vendor/github.com/hashicorp/terraform/helper/acctest/remotetests.go b/vendor/github.com/hashicorp/terraform/helper/acctest/remotetests.go deleted file mode 100644 index 87c60b8..0000000 --- a/vendor/github.com/hashicorp/terraform/helper/acctest/remotetests.go +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | package acctest | ||
2 | |||
3 | import ( | ||
4 | "net/http" | ||
5 | "os" | ||
6 | "testing" | ||
7 | ) | ||
8 | |||
9 | // SkipRemoteTestsEnvVar is an environment variable that can be set by a user | ||
10 | // running the tests in an environment with limited network connectivity. By | ||
11 | // default, tests requiring internet connectivity make an effort to skip if no | ||
12 | // internet is available, but in some cases the smoke test will pass even | ||
13 | // though the test should still be skipped. | ||
14 | const SkipRemoteTestsEnvVar = "TF_SKIP_REMOTE_TESTS" | ||
15 | |||
16 | // RemoteTestPrecheck is meant to be run by any unit test that requires | ||
17 | // outbound internet connectivity. The test will be skipped if it's | ||
18 | // unavailable. | ||
19 | func RemoteTestPrecheck(t *testing.T) { | ||
20 | if os.Getenv(SkipRemoteTestsEnvVar) != "" { | ||
21 | t.Skipf("skipping test, %s was set", SkipRemoteTestsEnvVar) | ||
22 | } | ||
23 | |||
24 | if _, err := http.Get("http://google.com"); err != nil { | ||
25 | t.Skipf("skipping, internet seems to not be available: %s", err) | ||
26 | } | ||
27 | } | ||