@@ -15,7 +15,7 @@ import (
1515
1616const (
1717 proxyGitlabTestSecret = "testSecret"
18- proxyGitlabTestEvent = "testEvent "
18+ proxyGitlabTestEvent = "Push Hook "
1919 proxyGitlabTestBody = "testBody"
2020 httpBinURL = "httpbin.org"
2121 httpBinURLInsecure = "http://" + httpBinURL
@@ -468,6 +468,7 @@ func TestProxy_proxyRequest(t *testing.T) {
468468 upstreamURL string
469469 allowedPaths []string
470470 secret string
471+ allowedUsers []string
471472 }
472473 type args struct {
473474 request * http.Request
@@ -603,6 +604,35 @@ func TestProxy_proxyRequest(t *testing.T) {
603604 },
604605 wantStatusCode : http .StatusMethodNotAllowed ,
605606 },
607+ {
608+ name : "TestProxyRequestShouldNotParseJsonWithoutAllowedOrIgnoredUsersConfigured" ,
609+ fields : fields {
610+ provider : providers .GitlabProviderKind ,
611+ upstreamURL : httpBinURLSecure ,
612+ allowedPaths : []string {},
613+ secret : "" ,
614+ },
615+ args : args {
616+ request : createGitlabRequestWithPayload (http .MethodPost , "/post" ,
617+ proxyGitlabTestSecret , proxyGitlabTestEvent , []byte ("{}" )),
618+ },
619+ wantStatusCode : http .StatusOK ,
620+ },
621+ {
622+ name : "TestProxyRequestShouldParseJsonWithAllowedOrIgnoredUsersConfigured" ,
623+ fields : fields {
624+ provider : providers .GitlabProviderKind ,
625+ upstreamURL : httpBinURLSecure ,
626+ allowedPaths : []string {},
627+ secret : "" ,
628+ allowedUsers : []string {"jsmith" },
629+ },
630+ args : args {
631+ request : createGitlabRequestWithPayload (http .MethodPost , "/post" ,
632+ proxyGitlabTestSecret , proxyGitlabTestEvent , proxyGitlabTestPayload ),
633+ },
634+ wantStatusCode : http .StatusOK ,
635+ },
606636 {
607637 name : "TestProxyRequestWithInvalidHttpMethod" ,
608638 fields : fields {
@@ -737,6 +767,7 @@ func TestProxy_proxyRequest(t *testing.T) {
737767 upstreamURL : tt .fields .upstreamURL ,
738768 allowedPaths : tt .fields .allowedPaths ,
739769 secret : tt .fields .secret ,
770+ allowedUsers : tt .fields .allowedUsers ,
740771 }
741772 router := httprouter .New ()
742773 router .POST ("/*path" , p .proxyRequest )
0 commit comments