-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1291 from hashicorp/gs/fix-testing
Fix acceptance test of Run Tasks
- Loading branch information
Showing
12 changed files
with
228 additions
and
210 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package provider | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
tfe "github.com/hashicorp/go-tfe" | ||
) | ||
|
||
type adminRoleType string | ||
|
||
const ( | ||
siteAdmin adminRoleType = "site-admin" | ||
configurationAdmin adminRoleType = "configuration" | ||
provisionLicensesAdmin adminRoleType = "provision-licenses" | ||
subscriptionAdmin adminRoleType = "subscription" | ||
supportAdmin adminRoleType = "support" | ||
securityMaintenanceAdmin adminRoleType = "security-maintenance" | ||
versionMaintenanceAdmin adminRoleType = "version-maintenance" | ||
) | ||
|
||
func getTokenForAdminRole(adminRole adminRoleType) string { | ||
token := "" | ||
|
||
switch adminRole { | ||
case siteAdmin: | ||
token = os.Getenv("TFE_ADMIN_SITE_ADMIN_TOKEN") | ||
case configurationAdmin: | ||
token = os.Getenv("TFE_ADMIN_CONFIGURATION_TOKEN") | ||
case provisionLicensesAdmin: | ||
token = os.Getenv("TFE_ADMIN_PROVISION_LICENSES_TOKEN") | ||
case subscriptionAdmin: | ||
token = os.Getenv("TFE_ADMIN_SUBSCRIPTION_TOKEN") | ||
case supportAdmin: | ||
token = os.Getenv("TFE_ADMIN_SUPPORT_TOKEN") | ||
case securityMaintenanceAdmin: | ||
token = os.Getenv("TFE_ADMIN_SECURITY_MAINTENANCE_TOKEN") | ||
case versionMaintenanceAdmin: | ||
token = os.Getenv("TFE_ADMIN_VERSION_MAINTENANCE_TOKEN") | ||
} | ||
|
||
return token | ||
} | ||
|
||
func testAdminClient(t *testing.T, adminRole adminRoleType) *tfe.Client { | ||
token := getTokenForAdminRole(adminRole) | ||
if token == "" { | ||
t.Fatal("missing API token for admin role " + adminRole) | ||
} | ||
|
||
client, err := tfe.NewClient(&tfe.Config{ | ||
Token: token, | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
return client | ||
} |
File renamed without changes.
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
Oops, something went wrong.