Skip to content

Commit

Permalink
Merge pull request #1002 from hashicorp/brandonc/nightlies
Browse files Browse the repository at this point in the history
TFE Nightlies
  • Loading branch information
brandonc authored Nov 13, 2024
2 parents 82dd272 + e18b09d commit b4b9a9b
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly-tfe-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
tests:
needs: instance
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
Expand Down
4 changes: 2 additions & 2 deletions admin_opa_version_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestAdminOPAVersions_List(t *testing.T) {

t.Run("with filter query string", func(t *testing.T) {
oList, err := client.Admin.OPAVersions.List(ctx, &AdminOPAVersionsListOptions{
Filter: "0.46.1",
Filter: "0.59.0",
})
require.NoError(t, err)
assert.Equal(t, 1, len(oList.Items))
Expand All @@ -80,7 +80,7 @@ func TestAdminOPAVersions_List(t *testing.T) {
})

t.Run("with search version query string", func(t *testing.T) {
searchVersion := "0.46.1"
searchVersion := "0.59.0"
oList, err := client.Admin.OPAVersions.List(ctx, &AdminOPAVersionsListOptions{
Search: searchVersion,
})
Expand Down
2 changes: 1 addition & 1 deletion admin_organization_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestAdminOrganizations_ModuleConsumers(t *testing.T) {
defer org1TestCleanup()

err := client.Admin.Organizations.UpdateModuleConsumers(ctx, org1.Name, []string{"1Hello!"})
assert.EqualError(t, err, ErrInvalidOrg.Error())
assert.Error(t, err, "Organization 1Hello! not found")
})

t.Run("can list and update module consumers", func(t *testing.T) {
Expand Down
18 changes: 14 additions & 4 deletions admin_run_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ func TestAdminRuns_List(t *testing.T) {
require.NoError(t, err)
require.NotEmpty(t, rl.Items)

assert.Equal(t, r1.Status, RunPlanning)
assert.Equal(t, adminRunItemsContainsID(rl.Items, r1.ID), false)
assert.Equal(t, r2.Status, RunPending)
assert.Equal(t, adminRunItemsContainsID(rl.Items, r2.ID), true)
})

Expand Down Expand Up @@ -189,7 +187,10 @@ func TestAdminRuns_ForceCancel(t *testing.T) {
t.Run("with can force cancel", func(t *testing.T) {
rTestPlanning, err := client.Runs.Read(ctx, rTest1.ID)
require.NoError(t, err)
assert.Equal(t, RunPlanning, rTestPlanning.Status)

ctxPollRunStatus, cancelPollPlanned := context.WithTimeout(ctx, 2*time.Minute)
defer cancelPollPlanned()
pollRunStatus(t, client, ctxPollRunStatus, rTestPlanning, []RunStatus{RunPlanning, RunPlanned, RunCostEstimated})

require.NotNil(t, rTestPlanning.Actions)
require.NotNil(t, rTestPlanning.Permissions)
Expand All @@ -198,7 +199,8 @@ func TestAdminRuns_ForceCancel(t *testing.T) {

rTestPending, err := client.Runs.Read(ctx, rTest2.ID)
require.NoError(t, err)
assert.Equal(t, RunPending, rTestPending.Status)

pollRunStatus(t, client, ctxPollRunStatus, rTest2, []RunStatus{RunPending})

require.NotNil(t, rTestPlanning.Actions)
require.NotNil(t, rTestPlanning.Permissions)
Expand Down Expand Up @@ -240,15 +242,23 @@ func TestAdminRuns_ListFilterByDates(t *testing.T) {
defer wTestCleanup()

timestamp1 := time.Now().Format(time.RFC3339)
// Sleeping helps ensure that the timestamps on client and server don't
// need to be exactly in sync
time.Sleep(2 * time.Second)

rTest1, rCleanup1 := createRun(t, client, wTest)
defer rCleanup1()

rTest2, rCleanup2 := createRun(t, client, wTest)
defer rCleanup2()

time.Sleep(2 * time.Second)
timestamp2 := time.Now().Format(time.RFC3339)

_, rCleanup3 := createRun(t, client, wTest)
defer rCleanup3()

time.Sleep(2 * time.Second)
timestamp3 := time.Now().Format(time.RFC3339)

t.Run("has valid date ranges", func(t *testing.T) {
Expand Down
18 changes: 16 additions & 2 deletions admin_setting_saml_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func TestAdminSettings_SAML_Update(t *testing.T) {
samlSettingsUpd, err := client.Admin.Settings.SAML.Update(ctx, AdminSAMLSettingsUpdateOptions{
Certificate: String(cert),
PrivateKey: String(pKey),
IDPCert: String(cert),
SLOEndpointURL: String("https://example.com/slo"),
SSOEndpointURL: String("https://example.com/sso"),
SignatureSigningMethod: String(signatureSigningMethod),
SignatureDigestMethod: String(signatureDigestMethod),
})
Expand All @@ -81,23 +84,34 @@ func TestAdminSettings_SAML_Update(t *testing.T) {
})

t.Run("with team management enabled", func(t *testing.T) {
cert := "testCert"
pKey := "testPrivateKey"
signatureSigningMethod := "SHA1"
signatureDigestMethod := "SHA1"

samlSettingsUpd, err := client.Admin.Settings.SAML.Update(ctx, AdminSAMLSettingsUpdateOptions{
Enabled: Bool(true),
TeamManagementEnabled: Bool(true),
Enabled: Bool(true),
TeamManagementEnabled: Bool(true),
Certificate: String(cert),
PrivateKey: String(pKey),
SignatureSigningMethod: String(signatureSigningMethod),
SignatureDigestMethod: String(signatureDigestMethod),
})
require.NoError(t, err)
assert.True(t, samlSettingsUpd.TeamManagementEnabled)
})

t.Run("with invalid signature digest method", func(t *testing.T) {
_, err := client.Admin.Settings.SAML.Update(ctx, AdminSAMLSettingsUpdateOptions{
AuthnRequestsSigned: Bool(true),
SignatureDigestMethod: String("SHA1234"),
})
require.Error(t, err)
})

t.Run("with invalid signature signing method", func(t *testing.T) {
_, err := client.Admin.Settings.SAML.Update(ctx, AdminSAMLSettingsUpdateOptions{
AuthnRequestsSigned: Bool(true),
SignatureSigningMethod: String("SHA1234"),
})
require.Error(t, err)
Expand Down
4 changes: 2 additions & 2 deletions admin_setting_smtp_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ func TestAdminSettings_SMTP_Update(t *testing.T) {
})
t.Run("with no Auth option", func(t *testing.T) {
smtpSettings, err := client.Admin.Settings.SMTP.Update(ctx, AdminSMTPSettingsUpdateOptions{
Enabled: Bool(enabled),
Enabled: Bool(disabled),
TestEmailAddress: String("[email protected]"),
Host: String("123"),
Port: Int(123),
})

require.NoError(t, err)
assert.Equal(t, SMTPAuthNone, smtpSettings.Auth)
assert.Equal(t, enabled, smtpSettings.Enabled)
assert.Equal(t, disabled, smtpSettings.Enabled)
})
t.Run("with invalid Auth option", func(t *testing.T) {
var SMTPAuthPlained SMTPAuthType = "plained"
Expand Down
4 changes: 2 additions & 2 deletions admin_user_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestAdminUsers_List(t *testing.T) {
PageSize: 100,
},
})

require.NoError(t, err)
// Out of range page number, so the items should be empty
assert.Empty(t, ul.Items)
Expand All @@ -55,10 +56,9 @@ func TestAdminUsers_List(t *testing.T) {

t.Run("query by username or email", func(t *testing.T) {
ul, err := client.Admin.Users.List(ctx, &AdminUserListOptions{
Query: currentUser.Username,
Query: "admin-security-maintenance",
})
require.NoError(t, err)
assert.Equal(t, currentUser.ID, ul.Items[0].ID)
assert.Equal(t, 1, ul.CurrentPage)
assert.Equal(t, true, ul.TotalCount == 1)

Expand Down
2 changes: 1 addition & 1 deletion helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ func createPolicyCheckedRun(t *testing.T, client *Client, w *Workspace) (*Run, f
}

func createPlannedRun(t *testing.T, client *Client, w *Workspace) (*Run, func()) {
return createRunWaitForStatus(t, client, w, RunCostEstimated)
return createRunWaitForAnyStatuses(t, client, w, []RunStatus{RunCostEstimated, RunPlanned})
}

func createCostEstimatedRun(t *testing.T, client *Client, w *Workspace) (*Run, func()) {
Expand Down
4 changes: 1 addition & 3 deletions organization_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func TestOrganizationsRead(t *testing.T) {
assert.NotEmpty(t, org.CreatedAt)
// By default accounts are in the free tier and are not in a trial
assert.Empty(t, org.TrialExpiresAt)
assert.Equal(t, org.RemainingTestableCount, 5)
assert.Greater(t, org.RemainingTestableCount, 1)
})
})

Expand All @@ -212,8 +212,6 @@ func TestOrganizationsRead(t *testing.T) {
})

t.Run("reads default project", func(t *testing.T) {
skipUnlessBeta(t)

org, err := client.Organizations.ReadWithOptions(ctx, orgTest.Name, OrganizationReadOptions{Include: []OrganizationIncludeOpt{OrganizationDefaultProject}})
require.NoError(t, err)
assert.Equal(t, orgTest.Name, org.Name)
Expand Down

0 comments on commit b4b9a9b

Please sign in to comment.