forked from TrueCloudLab/certificates
Initialize required variables on GetIdentityToken
Fixes smallstep/cli#465
This commit is contained in:
parent
352acf8faa
commit
40e77f6e9a
2 changed files with 12 additions and 0 deletions
|
@ -515,6 +515,11 @@ func (p *AWS) readURL(url string) ([]byte, error) {
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
// Initialize IMDS versions when this is called from the cli.
|
||||||
|
if len(p.IMDSVersions) == 0 {
|
||||||
|
p.IMDSVersions = []string{"v2", "v1"}
|
||||||
|
}
|
||||||
|
|
||||||
for _, v := range p.IMDSVersions {
|
for _, v := range p.IMDSVersions {
|
||||||
switch v {
|
switch v {
|
||||||
case "v1":
|
case "v1":
|
||||||
|
|
|
@ -141,6 +141,12 @@ func TestAWS_GetIdentityToken(t *testing.T) {
|
||||||
p7.config.signatureURL = p1.config.signatureURL
|
p7.config.signatureURL = p1.config.signatureURL
|
||||||
p7.config.tokenURL = p1.config.tokenURL
|
p7.config.tokenURL = p1.config.tokenURL
|
||||||
|
|
||||||
|
p8, err := generateAWS()
|
||||||
|
assert.FatalError(t, err)
|
||||||
|
p8.IMDSVersions = nil
|
||||||
|
p8.Accounts = p1.Accounts
|
||||||
|
p8.config = p1.config
|
||||||
|
|
||||||
caURL := "https://ca.smallstep.com"
|
caURL := "https://ca.smallstep.com"
|
||||||
u, err := url.Parse(caURL)
|
u, err := url.Parse(caURL)
|
||||||
assert.FatalError(t, err)
|
assert.FatalError(t, err)
|
||||||
|
@ -156,6 +162,7 @@ func TestAWS_GetIdentityToken(t *testing.T) {
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
{"ok", p1, args{"foo.local", caURL}, false},
|
{"ok", p1, args{"foo.local", caURL}, false},
|
||||||
|
{"ok no imds", p8, args{"foo.local", caURL}, false},
|
||||||
{"fail ca url", p1, args{"foo.local", "://ca.smallstep.com"}, true},
|
{"fail ca url", p1, args{"foo.local", "://ca.smallstep.com"}, true},
|
||||||
{"fail identityURL", p2, args{"foo.local", caURL}, true},
|
{"fail identityURL", p2, args{"foo.local", caURL}, true},
|
||||||
{"fail signatureURL", p3, args{"foo.local", caURL}, true},
|
{"fail signatureURL", p3, args{"foo.local", caURL}, true},
|
||||||
|
|
Loading…
Reference in a new issue