Skip to content

Commit

Permalink
test(policy): update TestPolicyCreateURL
Browse files Browse the repository at this point in the history
Use dynamic ($account-) policyID
add alert_rules build tag

ALLY-743
  • Loading branch information
hazedav authored Nov 29, 2021
1 parent b28d290 commit a89177c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ integration-only: ## Run integration tests
PATH=$(PWD)/bin:${PATH} go test -v github.com/lacework/go-sdk/integration -timeout 30m -tags="\
account \
agent_token \
alert_rules \
compliance \
configure \
event \
Expand Down
2 changes: 2 additions & 0 deletions integration/alert_rules_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build alert_rules

// Author:: Darren Murray (<[email protected]>)
// Copyright:: Copyright 2021, Lacework Inc.
// License:: Apache License, Version 2.0
Expand Down
9 changes: 3 additions & 6 deletions integration/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ alertProfile: LW_HE_Files.HE_File_NewViolation
policies:
- severity: low
`
policyURL string = "https://raw.githubusercontent.com/lacework/go-sdk/main/integration/test_resources/policy/lacework-clitest-1.json"
policyURL string = "https://raw.githubusercontent.com/lacework/go-sdk/main/integration/test_resources/policy/account-clitest-1.json"
)

var (
Expand Down Expand Up @@ -171,15 +171,12 @@ func TestPolicyCreateURL(t *testing.T) {
defer LaceworkCLIWithTOMLConfig("query", "delete", queryID)

// create (output human)
policyID := "$account-clitest-1"
out, stderr, exitcode := LaceworkCLIWithTOMLConfig("policy", "create", "-u", policyURL)
policyID, err := getPolicyIdFromStdout(out.String())
// teardown policy
defer LaceworkCLIWithTOMLConfig("policy", "delete", policyID)

assert.Nil(t, err)

assert.Contains(t, out.String(),
fmt.Sprintf("The policy %s was created.", policyID))
assert.Contains(t, out.String(), "clitest-1 was created.")
assert.Empty(t, stderr.String(), "STDERR should be empty")
assert.Equal(t, 0, exitcode, "EXITCODE is not the expected one")

Expand Down
13 changes: 0 additions & 13 deletions integration/test_resources/policy/lacework-clitest-1.json

This file was deleted.

0 comments on commit a89177c

Please sign in to comment.