Skip to content

Commit c93cd47

Browse files
committed
fix test merge issue
1 parent 523ee10 commit c93cd47

File tree

1 file changed

+0
-95
lines changed

1 file changed

+0
-95
lines changed

google/internal/externalaccount/aws_test.go

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,104 +1235,9 @@ func TestAWSCredential_ShouldCallMetadataEndpointWhenNoSecretAccessKey(t *testin
12351235
}
12361236
}
12371237

1238-
func TestAWSCredential_Validations(t *testing.T) {
1239-
var metadataServerValidityTests = []struct {
1240-
name string
1241-
credSource CredentialSource
1242-
errText string
1243-
}{
1244-
{
1245-
name: "No Metadata Server URLs",
1246-
credSource: CredentialSource{
1247-
EnvironmentID: "aws1",
1248-
RegionURL: "",
1249-
URL: "",
1250-
IMDSv2SessionTokenURL: "",
1251-
},
1252-
}, {
1253-
name: "IPv4 Metadata Server URLs",
1254-
credSource: CredentialSource{
1255-
EnvironmentID: "aws1",
1256-
RegionURL: "http://169.254.169.254/latest/meta-data/placement/availability-zone",
1257-
URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials",
1258-
IMDSv2SessionTokenURL: "http://169.254.169.254/latest/api/token",
1259-
},
1260-
}, {
1261-
name: "IPv6 Metadata Server URLs",
1262-
credSource: CredentialSource{
1263-
EnvironmentID: "aws1",
1264-
RegionURL: "http://[fd00:ec2::254]/latest/meta-data/placement/availability-zone",
1265-
URL: "http://[fd00:ec2::254]/latest/meta-data/iam/security-credentials",
1266-
IMDSv2SessionTokenURL: "http://[fd00:ec2::254]/latest/api/token",
1267-
},
1268-
}, {
1269-
name: "Faulty RegionURL",
1270-
credSource: CredentialSource{
1271-
EnvironmentID: "aws1",
1272-
RegionURL: "http://abc.com/latest/meta-data/placement/availability-zone",
1273-
URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials",
1274-
IMDSv2SessionTokenURL: "http://169.254.169.254/latest/api/token",
1275-
},
1276-
errText: "oauth2/google: invalid hostname http://abc.com/latest/meta-data/placement/availability-zone for region_url",
1277-
}, {
1278-
name: "Faulty CredVerificationURL",
1279-
credSource: CredentialSource{
1280-
EnvironmentID: "aws1",
1281-
RegionURL: "http://169.254.169.254/latest/meta-data/placement/availability-zone",
1282-
URL: "http://abc.com/latest/meta-data/iam/security-credentials",
1283-
IMDSv2SessionTokenURL: "http://169.254.169.254/latest/api/token",
1284-
},
1285-
errText: "oauth2/google: invalid hostname http://abc.com/latest/meta-data/iam/security-credentials for url",
1286-
}, {
1287-
name: "Faulty IMDSv2SessionTokenURL",
1288-
credSource: CredentialSource{
1289-
EnvironmentID: "aws1",
1290-
RegionURL: "http://169.254.169.254/latest/meta-data/placement/availability-zone",
1291-
URL: "http://169.254.169.254/latest/meta-data/iam/security-credentials",
1292-
IMDSv2SessionTokenURL: "http://abc.com/latest/api/token",
1293-
},
1294-
errText: "oauth2/google: invalid hostname http://abc.com/latest/api/token for imdsv2_session_token_url",
1295-
},
1296-
}
1297-
1298-
for _, tt := range metadataServerValidityTests {
1299-
t.Run(tt.name, func(t *testing.T) {
1300-
tfc := testFileConfig
1301-
tfc.CredentialSource = tt.credSource
1302-
1303-
oldGetenv := getenv
1304-
defer func() { getenv = oldGetenv }()
1305-
getenv = setEnvironment(map[string]string{})
1306-
1307-
_, err := tfc.parse(context.Background())
1308-
if err != nil {
1309-
if tt.errText == "" {
1310-
t.Errorf("Didn't expect an error, but got %v", err)
1311-
} else if tt.errText != err.Error() {
1312-
t.Errorf("Expected %v, but got %v", tt.errText, err)
1313-
}
1314-
} else {
1315-
if tt.errText != "" {
1316-
t.Errorf("Expected error %v, but got none", tt.errText)
1317-
}
1318-
}
1319-
})
1320-
}
1321-
}
1322-
13231238
func TestAwsCredential_CredentialSourceType(t *testing.T) {
13241239
server := createDefaultAwsTestServer()
13251240
ts := httptest.NewServer(server)
1326-
tsURL, err := neturl.Parse(ts.URL)
1327-
if err != nil {
1328-
t.Fatalf("couldn't parse httptest servername")
1329-
}
1330-
1331-
oldValidHostnames := validHostnames
1332-
defer func() {
1333-
validHostnames = oldValidHostnames
1334-
}()
1335-
validHostnames = []string{tsURL.Hostname()}
13361241

13371242
tfc := testFileConfig
13381243
tfc.CredentialSource = server.getCredentialSource(ts.URL)

0 commit comments

Comments
 (0)