-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cargo): allow configuration of Validate to check allow list for …
…release_source types Co-authored-by: Ajita Jain <jajita@vmware.com>
- Loading branch information
Showing
4 changed files
with
131 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package commands_test | ||
|
||
import ( | ||
"io" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/go-git/go-billy/v5" | ||
"github.com/go-git/go-billy/v5/memfs" | ||
|
||
"github.com/pivotal-cf/kiln/internal/commands" | ||
) | ||
|
||
var _ = Describe("validate", func() { | ||
var ( | ||
validate commands.Validate | ||
directory billy.Filesystem | ||
) | ||
|
||
BeforeEach(func() { | ||
directory = memfs.New() | ||
}) | ||
|
||
JustBeforeEach(func() { | ||
validate = commands.NewValidate(directory) | ||
}) | ||
|
||
When("the kilnfile has two release_sources", func() { | ||
BeforeEach(func() { | ||
f, err := directory.Create("Kilnfile") | ||
Expect(err).NotTo(HaveOccurred()) | ||
_, _ = io.WriteString(f, `--- | ||
release_sources: | ||
- type: "bosh.io" | ||
- type: "github" | ||
`) | ||
_ = f.Close() | ||
}) | ||
|
||
BeforeEach(func() { | ||
f, err := directory.Create("Kilnfile.lock") | ||
Expect(err).NotTo(HaveOccurred()) | ||
_ = f.Close() | ||
}) | ||
|
||
When("both types are in the allow list", func() { | ||
It("it does fail", func() { | ||
err := validate.Execute([]string{ | ||
"--allow-release-source-type=bosh.io", | ||
"--allow-release-source-type=github", | ||
}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
}) | ||
When("both one of the types is not in the allow list", func() { | ||
It("it does fail", func() { | ||
err := validate.Execute([]string{ | ||
"--allow-release-source-type=bosh.io", | ||
}) | ||
Expect(err).To(MatchError(ContainSubstring("release source type not allowed: github"))) | ||
}) | ||
}) | ||
}) | ||
|
||
}) |
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