(t *testing.T)
| 1207 | } |
| 1208 | |
| 1209 | func 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 | }, |
nothing calls this directly
no test coverage detected