summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2020-04-03 16:28:35 +1100
committerAsh McKenzie <amckenzie@gitlab.com>2020-04-17 16:23:33 +1000
commit2cb9461f0b188a18ff219cb1b5f12cb6b18a954b (patch)
tree173914db1b93ca94706b60112ac7e5b66205997c
parent95f34305e0701bc74e949e4b9b9a5b6ac44ecbb1 (diff)
downloadgitlab-shell-2cb9461f0b188a18ff219cb1b5f12cb6b18a954b.tar.gz
Allow allowedPayloadPath to be provided
-rw-r--r--internal/gitlabnet/accessverifier/client_test.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/internal/gitlabnet/accessverifier/client_test.go b/internal/gitlabnet/accessverifier/client_test.go
index 0b73fe9..888ea1c 100644
--- a/internal/gitlabnet/accessverifier/client_test.go
+++ b/internal/gitlabnet/accessverifier/client_test.go
@@ -52,7 +52,7 @@ func buildExpectedResponse(who string) *Response {
}
func TestSuccessfulResponses(t *testing.T) {
- client, cleanup := setup(t)
+ client, cleanup := setup(t, "")
defer cleanup()
testCases := []struct {
@@ -82,8 +82,8 @@ func TestSuccessfulResponses(t *testing.T) {
}
}
- client, cleanup := setup(t)
func TestGeoPushGetCustomAction(t *testing.T) {
+ client, cleanup := setup(t, "responses/allowed_with_push_payload.json")
defer cleanup()
args := &commandargs.Shell{GitlabUsername: "custom"}
@@ -106,7 +106,7 @@ func TestGeoPushGetCustomAction(t *testing.T) {
}
func TestErrorResponses(t *testing.T) {
- client, cleanup := setup(t)
+ client, cleanup := setup(t, "")
defer cleanup()
testCases := []struct {
@@ -142,7 +142,7 @@ func TestErrorResponses(t *testing.T) {
}
}
-func setup(t *testing.T) (*Client, func()) {
+func setup(t *testing.T, allowedPayload string) (*Client, func()) {
testDirCleanup, err := testhelper.PrepareTestRootDir()
require.NoError(t, err)
defer testDirCleanup()
@@ -150,9 +150,13 @@ func setup(t *testing.T) (*Client, func()) {
body, err := ioutil.ReadFile(path.Join(testhelper.TestRoot, "responses/allowed.json"))
require.NoError(t, err)
- allowedWithPayloadPath := path.Join(testhelper.TestRoot, "responses/allowed_with_push_payload.json")
- bodyWithPayload, err := ioutil.ReadFile(allowedWithPayloadPath)
- require.NoError(t, err)
+ var bodyWithPayload []byte
+
+ if allowedPayload != "" {
+ allowedWithPayloadPath := path.Join(testhelper.TestRoot, allowedPayload)
+ bodyWithPayload, err = ioutil.ReadFile(allowedWithPayloadPath)
+ require.NoError(t, err)
+ }
requests := []testserver.TestRequestHandler{
{