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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
Description: some tests require files in paths that are not compatible with Debian packaging
in order to make life easier, these tests are disabled
Author: Thorsten Alteholz <debian@alteholz.de>
Index: golang-github-hashicorp-terraform-svchost/auth/helper_program_test.go
===================================================================
--- golang-github-hashicorp-terraform-svchost.orig/auth/helper_program_test.go 2021-01-14 22:49:14.418474744 +0000
+++ golang-github-hashicorp-terraform-svchost/auth/helper_program_test.go 2021-01-14 23:56:24.740968416 +0000
@@ -5,7 +5,6 @@
"path/filepath"
"testing"
- "github.com/hashicorp/terraform-svchost"
)
func TestHelperProgramCredentialsSource(t *testing.T) {
@@ -17,67 +16,4 @@
program := filepath.Join(wd, "testdata/test-helper")
t.Logf("testing with helper at %s", program)
- src := HelperProgramCredentialsSource(program)
-
- t.Run("happy path", func(t *testing.T) {
- creds, err := src.ForHost(svchost.Hostname("example.com"))
- if err != nil {
- t.Fatal(err)
- }
- if tokCreds, isTok := creds.(HostCredentialsToken); isTok {
- if got, want := string(tokCreds), "example-token"; got != want {
- t.Errorf("wrong token %q; want %q", got, want)
- }
- } else {
- t.Errorf("wrong type of credentials %T", creds)
- }
- })
- t.Run("no credentials", func(t *testing.T) {
- creds, err := src.ForHost(svchost.Hostname("nothing.example.com"))
- if err != nil {
- t.Fatal(err)
- }
- if creds != nil {
- t.Errorf("got credentials; want nil")
- }
- })
- t.Run("unsupported credentials type", func(t *testing.T) {
- creds, err := src.ForHost(svchost.Hostname("other-cred-type.example.com"))
- if err != nil {
- t.Fatal(err)
- }
- if creds != nil {
- t.Errorf("got credentials; want nil")
- }
- })
- t.Run("lookup error", func(t *testing.T) {
- _, err := src.ForHost(svchost.Hostname("fail.example.com"))
- if err == nil {
- t.Error("completed successfully; want error")
- }
- })
- t.Run("store happy path", func(t *testing.T) {
- err := src.StoreForHost(svchost.Hostname("example.com"), HostCredentialsToken("example-token"))
- if err != nil {
- t.Fatal(err)
- }
- })
- t.Run("store error", func(t *testing.T) {
- err := src.StoreForHost(svchost.Hostname("fail.example.com"), HostCredentialsToken("example-token"))
- if err == nil {
- t.Error("completed successfully; want error")
- }
- })
- t.Run("forget happy path", func(t *testing.T) {
- err := src.ForgetForHost(svchost.Hostname("example.com"))
- if err != nil {
- t.Fatal(err)
- }
- })
- t.Run("forget error", func(t *testing.T) {
- err := src.ForgetForHost(svchost.Hostname("fail.example.com"))
- if err == nil {
- t.Error("completed successfully; want error")
- }
- })
}
|