Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mrinalirao committed Aug 14, 2023
1 parent 7533efc commit b871934
Show file tree
Hide file tree
Showing 5 changed files with 367 additions and 741 deletions.
42 changes: 35 additions & 7 deletions policy_evaluation_beta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ import (
)

func TestPolicyEvaluationList_Beta(t *testing.T) {
skipUnlessBeta(t)
//skipUnlessBeta(t)

Check failure on line 15 in policy_evaluation_beta_test.go

View workflow job for this annotation

GitHub Actions / Lint

commentFormatting: put a space between `//` and comment text (gocritic)

client := testClient(t)
ctx := context.Background()

orgTest, orgTestCleanup := createOrganization(t, client)
defer orgTestCleanup()

upgradeOrganizationSubscription(t, client, orgTest)

wkspaceTest, wkspaceTestCleanup := createWorkspace(t, client, orgTest)
defer wkspaceTestCleanup()

Expand Down Expand Up @@ -67,14 +69,16 @@ func TestPolicyEvaluationList_Beta(t *testing.T) {
}

func TestPolicySetOutcomeList_Beta(t *testing.T) {
skipUnlessBeta(t)
//skipUnlessBeta(t)

Check failure on line 72 in policy_evaluation_beta_test.go

View workflow job for this annotation

GitHub Actions / Lint

commentFormatting: put a space between `//` and comment text (gocritic)

client := testClient(t)
ctx := context.Background()

orgTest, orgTestCleanup := createOrganization(t, client)
defer orgTestCleanup()

upgradeOrganizationSubscription(t, client, orgTest)

wkspaceTest, wkspaceTestCleanup := createWorkspace(t, client, orgTest)
defer wkspaceTestCleanup()

Expand All @@ -88,14 +92,14 @@ func TestPolicySetOutcomeList_Beta(t *testing.T) {
},
},
}
policyTest, policyTestCleanup := createUploadedPolicyWithOptions(t, client, true, orgTest, options)
policyTest, policyTestCleanup := createUploadedPolicyWithOptions(t, client, false, orgTest, options)
defer policyTestCleanup()

policySet := []*Policy{policyTest}
_, psTestCleanup1 := createPolicySet(t, client, orgTest, policySet, []*Workspace{wkspaceTest}, nil, OPA)
defer psTestCleanup1()

rTest, rTestCleanup := createPlannedRun(t, client, wkspaceTest)
rTest, rTestCleanup := createRunWaitForStatus(t, client, wkspaceTest, RunErrored)
defer rTestCleanup()

t.Run("with no params", func(t *testing.T) {
Expand All @@ -112,8 +116,18 @@ func TestPolicySetOutcomeList_Beta(t *testing.T) {
polSetOutcomesList, err := client.PolicySetOutcomes.List(ctx, polEvaluationID, nil)
require.NoError(t, err)

t.Log("-------------------")
t.Log(polSetOutcomesList.Items[0])
t.Log(polSetOutcomesList.Items[0].ID)
t.Log(polSetOutcomesList.Items[0].PolicySetName)
t.Log("???-------------------???")
t.Log(polSetOutcomesList.Items[0].ResultCount)

require.NotEmpty(t, polSetOutcomesList.Items)
assert.NotEmpty(t, polSetOutcomesList.Items[0].ID)
t.Log("............................")
t.Log(polSetOutcomesList.Items[0].Outcomes)

assert.NotEmpty(t, polSetOutcomesList.Items[0].Outcomes)
assert.NotEmpty(t, polSetOutcomesList.Items[0].PolicySetName)
})
Expand Down Expand Up @@ -161,7 +175,7 @@ func TestPolicySetOutcomeList_Beta(t *testing.T) {
opts := &PolicySetOutcomeListOptions{
Filter: map[string]PolicySetOutcomeListFilter{
"0": {
Status: "passed",
//Status: "passed",
EnforcementLevel: "advisory",
},
},
Expand All @@ -170,6 +184,14 @@ func TestPolicySetOutcomeList_Beta(t *testing.T) {
polSetOutcomesList, err := client.PolicySetOutcomes.List(ctx, polEvaluationID, opts)
require.NoError(t, err)

t.Log("-------------------")
t.Log(polSetOutcomesList.Items)
t.Log(polSetOutcomesList.Items[0])
t.Log(string(polSetOutcomesList.Items[0].ID))
t.Log(polSetOutcomesList.Items[0].PolicySetName)
t.Log("............................")
t.Log(polSetOutcomesList.Items[0].Outcomes)

require.NotEmpty(t, polSetOutcomesList.Items)
assert.NotEmpty(t, polSetOutcomesList.Items[0].ID)
assert.Equal(t, 1, len(polSetOutcomesList.Items[0].Outcomes))
Expand All @@ -186,6 +208,8 @@ func TestPolicySetOutcomeRead_Beta(t *testing.T) {
orgTest, orgTestCleanup := createOrganization(t, client)
defer orgTestCleanup()

upgradeOrganizationSubscription(t, client, orgTest)

wkspaceTest, wkspaceTestCleanup := createWorkspace(t, client, orgTest)
defer wkspaceTestCleanup()

Expand All @@ -203,10 +227,14 @@ func TestPolicySetOutcomeRead_Beta(t *testing.T) {
defer policyTestCleanup()

policySet := []*Policy{policyTest}
_, psTestCleanup1 := createPolicySet(t, client, orgTest, policySet, []*Workspace{wkspaceTest}, nil, OPA)
policySetOpts := PolicySetCreateOptions{
Kind: OPA,
Overridable: Bool(true),
}
_, psTestCleanup1 := createPolicySetWithOptions(t, client, orgTest, policySet, []*Workspace{wkspaceTest}, policySetOpts)
defer psTestCleanup1()

rTest, rTestCleanup := createPlannedRun(t, client, wkspaceTest)
rTest, rTestCleanup := createRunWaitForStatus(t, client, wkspaceTest, RunPostPlanAwaitingDecision)
defer rTestCleanup()

t.Run("with a valid policy set outcome ID", func(t *testing.T) {
Expand Down
Loading

0 comments on commit b871934

Please sign in to comment.