Skip to content

Commit

Permalink
NewChaosProbeOperator
Browse files Browse the repository at this point in the history
  • Loading branch information
andoriyaprashant committed Jan 19, 2025
1 parent 9911bd9 commit 8e69135
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ func (c *ChaosExperimentHandler) GetProbesInExperimentRun(ctx context.Context, p
}

for _, probeName := range _probe.ProbeNames {
singleProbe, err := dbSchemaProbe.NewChaosProbeOperator(c.mongodbOperator).GetProbeByName(ctx, probeName, projectID)
singleProbe, err := dbSchemaProbe.NewProbeOperator(c.mongodbOperator).GetProbeByName(ctx, probeName, projectID)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"reflect"
"testing"

"github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/authorization"
dbSchemaProbe "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/probe"

"github.com/gin-gonic/gin"
Expand All @@ -30,11 +31,12 @@ import (

var (
mongodbMockOperator = new(dbMocks.MongoOperator)
probeOperator = dbSchemaProbe.NewChaosProbeOperator(mongodbMockOperator)
probeOperator = dbSchemaProbe.NewProbeOperator(mongodbMockOperator)
infraOperator = dbChaosInfra.NewInfrastructureOperator(mongodbMockOperator)
chaosExperimentOperator = dbChaosExperiment.NewChaosExperimentOperator(mongodbMockOperator)
chaosExperimentRunOperator = dbChaosExperimentRun.NewChaosExperimentRunOperator(mongodbMockOperator)
probeService = probe.NewProbeService(probeOperator)
authConfigOperator = authorization.NewAuthorizationOperator(mongodbMockOperator)
probeService = probe.NewProbeService(probeOperator, authConfigOperator)
)

var chaosExperimentRunTestService = NewChaosExperimentService(chaosExperimentOperator, infraOperator, chaosExperimentRunOperator, probeService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type ChaosExperimentRunHandler struct {
chaosExperimentRunOperator *dbChaosExperimentRun.Operator
probeService probe.Service
mongodbOperator mongodb.MongoOperator
authConfigOperator *authorization.Operator
}

// NewChaosExperimentRunHandler returns a new instance of ChaosWorkflowHandler
Expand All @@ -67,6 +68,7 @@ func NewChaosExperimentRunHandler(
chaosExperimentRunOperator *dbChaosExperimentRun.Operator,
probeService probe.Service,
mongodbOperator mongodb.MongoOperator,
authConfigOperator *authorization.Operator,
) *ChaosExperimentRunHandler {
return &ChaosExperimentRunHandler{
chaosExperimentRunService: chaosExperimentRunService,
Expand All @@ -76,6 +78,7 @@ func NewChaosExperimentRunHandler(
chaosExperimentRunOperator: chaosExperimentRunOperator,
probeService: probeService,
mongodbOperator: mongodbOperator,
authConfigOperator: authConfigOperator,
}
}

Expand Down Expand Up @@ -799,7 +802,7 @@ func (c *ChaosExperimentRunHandler) RunChaosWorkFlow(ctx context.Context, projec
)

tkn := ctx.Value(authorization.AuthKey).(string)
username, err := authorization.GetUsername(tkn)
username, err := c.authConfigOperator.GetUsername(tkn)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1003,7 +1006,7 @@ func (c *ChaosExperimentRunHandler) RunCronExperiment(ctx context.Context, proje
}

tkn := ctx.Value(authorization.AuthKey).(string)
username, err := authorization.GetUsername(tkn)
username, err := c.authConfigOperator.GetUsername(tkn)
if err != nil {
return err
}
Expand Down

0 comments on commit 8e69135

Please sign in to comment.