Skip to content

Commit

Permalink
add policy path for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuf Kanchwala committed Oct 2, 2020
1 parent a332115 commit 8492103
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions pkg/http-server/remote-repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ func (g *APIHandler) scanRemoteRepo(w http.ResponseWriter, r *http.Request) {

// scan remote repo
s.d = downloader.NewDownloader()
results, err := s.ScanRemoteRepo(iacType, iacVersion, cloudType)
var results interface{}
if g.test {
results, err = s.ScanRemoteRepo(iacType, iacVersion, cloudType, "./testdata/testpolicies")

} else {
results, err = s.ScanRemoteRepo(iacType, iacVersion, cloudType, "")
}
if err != nil {
apiErrorResponse(w, err.Error(), http.StatusBadRequest)
return
Expand All @@ -83,7 +89,7 @@ func (g *APIHandler) scanRemoteRepo(w http.ResponseWriter, r *http.Request) {

// ScanRemoteRepo is the actual method where a remote repo is downloaded and
// scanned for violations
func (s *scanRemoteRepoReq) ScanRemoteRepo(iacType, iacVersion, cloudType string) (interface{}, error) {
func (s *scanRemoteRepoReq) ScanRemoteRepo(iacType, iacVersion, cloudType, policyPath string) (interface{}, error) {

// return params
var (
Expand All @@ -105,7 +111,7 @@ func (s *scanRemoteRepoReq) ScanRemoteRepo(iacType, iacVersion, cloudType string

// create a new runtime executor for scanning the remote repo
executor, err := runtime.NewExecutor(iacType, iacVersion, cloudType,
"", iacDirPath, "", "")
"", iacDirPath, "", policyPath)
if err != nil {
zap.S().Error(err)
return output, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/http-server/remote-repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestScanRemoteRepo(t *testing.T) {

for _, tt := range table {
t.Run(tt.name, func(t *testing.T) {
gotOutput, gotErr := tt.s.ScanRemoteRepo(tt.iacType, tt.iacVersion, tt.cloudType)
gotOutput, gotErr := tt.s.ScanRemoteRepo(tt.iacType, tt.iacVersion, tt.cloudType, "")
if !reflect.DeepEqual(gotErr, tt.wantErr) {
t.Errorf("error got: '%v', want: '%v'", gotErr, tt.wantErr)
}
Expand Down

0 comments on commit 8492103

Please sign in to comment.