MCPcopy Create free account
hub / github.com/clouditor/clouditor / TestService_evaluateControl

Function TestService_evaluateControl

service/evaluation/evaluation_test.go:1209–1351  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1207}
1208
1209func TestService_evaluateControl(t *testing.T) {
1210 type fields struct {
1211 orchestrator *api.RPCConnection[orchestrator.OrchestratorClient]
1212 scheduler *gocron.Scheduler
1213 storage persistence.Storage
1214 authz service.AuthorizationStrategy
1215 catalogControls map[string]map[string]*orchestrator.Control
1216 }
1217 type args struct {
1218 ctx context.Context
1219 auditScope *orchestrator.AuditScope
1220 catalog *orchestrator.Catalog
1221 control *orchestrator.Control
1222 manual []*evaluation.EvaluationResult
1223 }
1224 tests := []struct {
1225 name string
1226 fields fields
1227 args args
1228 newEvaluationResults *evaluation.EvaluationResult
1229 want func(t *testing.T, gotSvc *Service, gotResult *evaluation.EvaluationResult) bool
1230 }{
1231 {
1232 name: "AuthZ error in ListEvaluationResults",
1233 fields: fields{
1234 storage: testutil.NewInMemoryStorage(t, func(s persistence.Storage) {
1235 assert.NoError(t, s.Create(evaluationtest.MockEvaluationResultsWithoutResultsForParentControl))
1236 }),
1237 authz: &service.AuthorizationStrategyJWT{},
1238 },
1239 args: args{
1240 ctx: context.Background(),
1241 auditScope: &orchestrator.AuditScope{
1242 CertificationTargetId: testdata.MockCertificationTargetID1,
1243 CatalogId: testdata.MockCatalogID,
1244 AssuranceLevel: &testdata.AssuranceLevelHigh,
1245 },
1246 catalog: orchestratortest.NewCatalog(),
1247 control: orchestratortest.MockControl1,
1248 },
1249 newEvaluationResults: &evaluation.EvaluationResult{},
1250 want: func(t *testing.T, gotSvc *Service, gotResult *evaluation.EvaluationResult) bool {
1251 evalResults, err := gotSvc.ListEvaluationResults(context.Background(), &evaluation.ListEvaluationResultsRequest{})
1252 assert.NoError(t, err)
1253 return assert.Equal(t, 0, len(evalResults.Results))
1254 },
1255 },
1256 {
1257 name: "No assessment results for evaluation available",
1258 fields: fields{
1259 storage: testutil.NewInMemoryStorage(t),
1260 authz: &service.AuthorizationStrategyAllowAll{},
1261 orchestrator: api.NewRPCConnection(testdata.MockGRPCTarget, orchestrator.NewOrchestratorClient, grpc.WithContextDialer(newBufConnDialer(testutil.NewInMemoryStorage(t)))),
1262 catalogControls: map[string]map[string]*orchestrator.Control{
1263 testdata.MockCatalogID: {
1264 testdata.MockCategoryName + "-" + testdata.MockControlID1: orchestratortest.MockControl1,
1265 testdata.MockCategoryName + "-" + testdata.MockSubControlID11: orchestratortest.MockControl11,
1266 },

Callers

nothing calls this directly

Calls 9

evaluateControlMethod · 0.95
NewInMemoryStorageFunction · 0.92
NewCatalogFunction · 0.92
EqualFunction · 0.92
NewRPCConnectionFunction · 0.92
NotNilFunction · 0.92
newBufConnDialerFunction · 0.85
CreateMethod · 0.65
ListEvaluationResultsMethod · 0.65

Tested by

no test coverage detected