generated from hashicorp/packer-plugin-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Impl use of content of the service account key file in the environmen…
…t variable `YC_SERVICE_ACCOUNT_KEY_FILE` (#82) * Set up-to-date Ubuntu version * Support SA Key file content JSON format in `YC_SERVICE_ACCOUNT_KEY_FILE` Closes #39 * Update generated docs --------- Co-authored-by: Wilken Rivera <[email protected]>
- Loading branch information
1 parent
0b7113e
commit b5cc132
Showing
12 changed files
with
143 additions
and
26 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 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
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,67 @@ | ||
package yandex | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAccessConfig_Prepare(t *testing.T) { | ||
bytes, err := os.ReadFile(TestServiceAccountKeyFile) | ||
require.NoErrorf(t, err, "failed to read file %s", TestServiceAccountKeyFile) | ||
|
||
var TestServiceAccountKeyFileContent = string(bytes) | ||
|
||
type fields struct { | ||
Endpoint string | ||
ServiceAccountKeyFile string | ||
Token string | ||
MaxRetries int | ||
saKeyType keyType | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want []error | ||
}{ | ||
{ | ||
name: "sa_key_as_file", fields: fields{ | ||
Endpoint: "", | ||
ServiceAccountKeyFile: TestServiceAccountKeyFile, | ||
Token: "", | ||
}, | ||
want: nil, | ||
}, | ||
{ | ||
name: "sa_key_as_json_content", fields: fields{ | ||
ServiceAccountKeyFile: TestServiceAccountKeyFileContent, | ||
Token: "", | ||
}, | ||
want: nil, | ||
}, | ||
{ | ||
name: "both_identities", fields: fields{ | ||
ServiceAccountKeyFile: TestServiceAccountKeyFileContent, | ||
Token: "t1.super-token", | ||
}, | ||
want: []error{errors.New("one of token or service account key file must be specified, not both")}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
ctx := &interpolate.Context{} | ||
c := &AccessConfig{ | ||
Endpoint: tt.fields.Endpoint, | ||
ServiceAccountKeyFile: tt.fields.ServiceAccountKeyFile, | ||
Token: tt.fields.Token, | ||
MaxRetries: tt.fields.MaxRetries, | ||
saKeyType: tt.fields.saKeyType, | ||
} | ||
assert.Equalf(t, tt.want, c.Prepare(ctx), "Prepare(%v)") | ||
}) | ||
} | ||
} |
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
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