Skip to content

Commit

Permalink
Merge branch 'keploy:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
yaten2302 authored Dec 20, 2024
2 parents 1a294a9 + f523fd6 commit ed4a867
Show file tree
Hide file tree
Showing 18 changed files with 693 additions and 428 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ jobs:
- name: Create a folder for security reports
run: mkdir -p reports

- name: Generate Security Report
uses: peter-murray/github-security-report-action@v2
with:
token: ${{ secrets.CODEQL_EXPORT_PAT_TOKEN }}
outputDir: ./reports
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: security-report
path: /home/runner/work/keploy/results
# - name: Generate Security Report
# uses: peter-murray/github-security-report-action@v2
# with:
# token: ${{ secrets.CODEQL_EXPORT_PAT_TOKEN }}
# outputDir: ./reports
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: security-report
# path: /home/runner/work/keploy/results
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ done

# Start keploy in test mode.
test_container="echoApp"
test_container_logs="echoTest"
sudo -E env PATH=$PATH ./../../keployv2 test -c 'docker compose up' --containerName "$test_container" --apiTimeout 60 --delay 20 --generate-github-actions=false &> "${test_container_logs}.txt"
sudo -E env PATH=$PATH ./../../keployv2 test -c 'docker compose up' --containerName "$test_container" --apiTimeout 60 --delay 20 --generate-github-actions=false &> "${test_container}.txt"

if grep "ERROR" "${test_container}.txt"; then
echo "Error found in pipeline..."
Expand Down
69 changes: 69 additions & 0 deletions cli/import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package cli

import (
"context"

"github.com/spf13/cobra"
"go.keploy.io/server/v2/cli/provider"
"go.keploy.io/server/v2/config"
toolsSvc "go.keploy.io/server/v2/pkg/service/tools"
"go.keploy.io/server/v2/utils"
"go.uber.org/zap"
)

func init() {
Register("import", Import)
}

func Import(ctx context.Context, logger *zap.Logger, _ *config.Config, serviceFactory ServiceFactory, cmdConfigurator CmdConfigurator) *cobra.Command {

var importCmd = &cobra.Command{
Use: "import",
Short: "import postman collection to Keploy tests",
Example: "keploy import",
RunE: func(cmd *cobra.Command, _ []string) error {
disableAnsi, _ := (cmd.Flags().GetBool("disable-ansi"))
provider.PrintLogo(disableAnsi)
return cmd.Help()
},
}
var postmanCmd = &cobra.Command{
Use: "postman",
Short: "import postman collection to Keploy tests",
Example: "keploy import postman",
RunE: func(cmd *cobra.Command, _ []string) error {
disableAnsi, _ := (cmd.Flags().GetBool("disable-ansi"))
provider.PrintLogo(disableAnsi)
path, _ := cmd.Flags().GetString("path")
if path == "" {
path = "output.json"
}
svc, err := serviceFactory.GetService(ctx, "import")
if err != nil {
utils.LogError(logger, err, "failed to get service")
return nil
}
var tools toolsSvc.Service
var ok bool
if tools, ok = svc.(toolsSvc.Service); !ok {
utils.LogError(logger, nil, "service doesn't satisfy tools service interface")
return nil
}
err = tools.Import(ctx, path)
if err != nil {
utils.LogError(logger, err, "failed to import Postman collection")
}
return nil
},
}
importCmd.AddCommand(postmanCmd)

for _, subCmd := range importCmd.Commands() {
err := cmdConfigurator.AddFlags(subCmd)
if err != nil {
utils.LogError(logger, err, "failed to add flags to command", zap.String("command", subCmd.Name()))
}
}

return importCmd
}
6 changes: 4 additions & 2 deletions cli/provider/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ func (c *CmdConfigurator) AddFlags(cmd *cobra.Command) error {
cmd.Flags().String("driven", c.cfg.Contract.Driven, "Specify the path to download contracts")
}

case "update", "export":
case "update", "export", "import":
return nil
case "postman":
cmd.Flags().StringP("path", "p", "", "Specify the path to the postman collection")
case "normalize":
cmd.Flags().StringP("path", "p", ".", "Path to local directory where generated testcases/mocks/reports are stored")
cmd.Flags().String("test-run", "", "Test Run to be normalized")
Expand Down Expand Up @@ -289,7 +291,7 @@ func (c *CmdConfigurator) AddUncommonFlags(cmd *cobra.Command) {
cmd.Flags().Bool("fallBack-on-miss", c.cfg.Test.FallBackOnMiss, "Enable connecting to actual service if mock not found during test mode")
cmd.Flags().String("jacoco-agent-path", c.cfg.Test.JacocoAgentPath, "Only applicable for test coverage for Java projects. You can override the jacoco agent jar by proving its path")
cmd.Flags().String("base-path", c.cfg.Test.BasePath, "Custom api basePath/origin to replace the actual basePath/origin in the testcases; App flag is ignored and app will not be started & instrumented when this is set since the application running on a different machine")
cmd.Flags().Bool("update-temp", c.cfg.Test.UpdateTemplate, "Update the template with the result of the testcases.")
cmd.Flags().Bool("update-template", c.cfg.Test.UpdateTemplate, "Update the template with the result of the testcases.")
cmd.Flags().Bool("mocking", true, "enable/disable mocking for the testcases")
cmd.Flags().Bool("disableMockUpload", c.cfg.Test.DisableMockUpload, "Store/Fetch mocks locally")
cmd.Flags().Bool("useLocalMock", false, "Use local mocks instead of fetching from the cloud")
Expand Down
2 changes: 1 addition & 1 deletion cli/provider/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (n *ServiceProvider) GetService(ctx context.Context, cmd string) (interface
tel.Ping()

switch cmd {
case "config", "update", "login", "export":
case "config", "update", "login", "export", "import":
return tools.NewTools(n.logger, tel, n.auth), nil
case "gen":
return utgen.NewUnitTestGenerator(n.cfg, tel, n.auth, n.logger)
Expand Down
10 changes: 3 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/docker/docker v24.0.4+incompatible
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fatih/color v1.16.0
github.com/fatih/color v1.17.0
github.com/k0kubun/pp/v3 v3.2.0
github.com/miekg/dns v1.1.55
github.com/moby/term v0.5.0 // indirect
Expand Down Expand Up @@ -47,24 +47,20 @@ require (
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tidwall/gjson v1.17.0 // indirect
github.com/tidwall/gjson v1.17.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/yudai/pp v2.0.1+incompatible // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down Expand Up @@ -115,13 +111,13 @@ require (
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.6.0
github.com/jackc/pgproto3/v2 v2.3.2
github.com/keploy/jsonDiff v1.0.4
github.com/shirou/gopsutil/v3 v3.24.3
github.com/spf13/viper v1.19.0
github.com/wI2L/jsondiff v0.5.0
github.com/xdg-go/pbkdf2 v1.0.0
github.com/xdg-go/scram v1.1.1
github.com/xdg-go/stringprep v1.0.4
github.com/yudai/gojsondiff v1.0.0
golang.org/x/sync v0.7.0
golang.org/x/term v0.21.0
gopkg.in/yaml.v2 v2.4.0
Expand Down
Loading

0 comments on commit ed4a867

Please sign in to comment.