Repository: clouditor/clouditor
Pull request #470 (2022-01-27 14:41:01)

Add validation for assessment result ID
- #463 

codecov[bot]: # [Codecov](https://codecov.io/gh/clouditor/clouditor/pull/470?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor) Report
> Merging [#470](https://codecov.io/gh/clouditor/clouditor/pull/470?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor) (bed665f) into [main](https://codecov.io/gh/clouditor/clouditor/commit/9e44adc27dac2cf3dce854cd4891c74ea4b13f13?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor) (9e44adc) will **increase** coverage by `0.01%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/clouditor/clouditor/pull/470/graphs/tree.svg?width=650&height=150&src=pr&token=syrXsw5LTX&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor)](https://codecov.io/gh/clouditor/clouditor/pull/470?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor)

```diff
@@            Coverage Diff             @@
##             main     #470      +/-   ##
==========================================
+ Coverage   76.00%   76.01%   +0.01%     
==========================================
  Files          44       44              
  Lines        3750     3753       +3     
==========================================
+ Hits         2850     2853       +3     
  Misses        774      774              
  Partials      126      126              
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `76.01% <100.00%> (+0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/clouditor/clouditor/pull/470?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor) | Coverage Δ | |
|---|---|---|
| [api/assessment/assessment.go](https://codecov.io/gh/clouditor/clouditor/pull/470/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor#diff-YXBpL2Fzc2Vzc21lbnQvYXNzZXNzbWVudC5nbw==) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/clouditor/clouditor/pull/470?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/clouditor/clouditor/pull/470?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor). Last update [9e44adc...bed665f](https://codecov.io/gh/clouditor/clouditor/pull/470?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=clouditor).

oxisto: > Shouldn't we check the resourceID as well?

Yes, I included this as well. The resource ID does not follow any convention (yet). So I am just checking for pure existence. 

I also removed the wrapping of the UUID error codes, since my gut feeling says that this is not a good idea from a security point of view. I would keep the validation errors constant without any means to reflect values back to somehow who potentially inserts weird values.

Patch:
diff --git a/api/assessment/assessment.go b/api/assessment/assessment.go
index f3f2e617..0f2a0c34 100644
--- a/api/assessment/assessment.go
+++ b/api/assessment/assessment.go
@@ -25,22 +25,31 @@
 
 package assessment
 
-import "errors"
+import (
+	"errors"
+
+	"github.com/google/uuid"
+)
 
 type ResultHookFunc func(result *AssessmentResult, err error)
 
 var (
+	ErrIdInvalidFormat                       = errors.New("assessment result id not in expected format (UUID) or missing")
+	ErrEvidenceIdInvalidFormat               = errors.New("evidence id not in expected format (UUID) or missing")
 	ErrTimestampMissing                      = errors.New("timestamp in assessment result is missing")
+	ErrResourceIdMissing                     = errors.New("resource id in assessment result is missing")
 	ErrMetricIdMissing                       = errors.New("metric id in assessment result is missing")
 	ErrMetricConfigurationMissing            = errors.New("metric configuration in assessment result is missing")
-	ErrEvidenceIdMissing                     = errors.New("evidence id in assessment result is missing")
-	ErrNonComplianceCommentsMissing          = errors.New("non-compliance comments in assessment result is missing")
 	ErrMetricConfigurationOperatorMissing    = errors.New("operator in metric data is missing")
 	ErrMetricConfigurationTargetValueMissing = errors.New("target value in metric data is missing")
 )
 
 // Validate validates the assessment result according to several required fields
 func (result *AssessmentResult) Validate() (resourceId string, err error) {
+	if _, err = uuid.Parse(result.Id); err != nil {
+		return "", ErrIdInvalidFormat
+	}
+
 	if result.Timestamp == nil {
 		return "", ErrTimestampMissing
 	}
@@ -61,11 +70,13 @@ func (result *AssessmentResult) Validate() (resourceId string, err error) {
 		return "", ErrMetricConfigurationTargetValueMissing
 	}
 
-	if result.EvidenceId == "" {
-		return "", ErrEvidenceIdMissing
+	if _, err = uuid.Parse(result.EvidenceId); err != nil {
+		return "", ErrEvidenceIdInvalidFormat
 	}
 
-	// TODO(garuppel): Missing resource ID?
+	if result.ResourceId == "" {
+		return "", ErrResourceIdMissing
+	}
 
 	return
 }
diff --git a/cli/session.go b/cli/session.go
index fe1ce5ce..ea31dc24 100644
--- a/cli/session.go
+++ b/cli/session.go
@@ -102,8 +102,9 @@ func ContinueSession() (session *Session, err error) {
 		return
 	}
 
-	// TODO(all): Should we catch errors of deferred close operations?
-	defer file.Close()
+	defer func(file *os.File) {
+		err = file.Close()
+	}(file)
 
 	session = new(Session)
 	session.Folder = folder
@@ -134,8 +135,9 @@ func (s *Session) Save() (err error) {
 		return fmt.Errorf("could not save session.json: %w", err)
 	}
 
-	// TODO(all): Should we catch errors of deferred close operations?
-	defer file.Close()
+	defer func(file *os.File) {
+		err = file.Close()
+	}(file)
 
 	if err = json.NewEncoder(file).Encode(s); err != nil {
 		return fmt.Errorf("could not serialize JSON: %w", err)
@@ -145,7 +147,7 @@ func (s *Session) Save() (err error) {
 }
 
 // HandleResponse handles the response and error message of an gRPC call
-func (s *Session) HandleResponse(msg proto.Message, err error) error {
+func (*Session) HandleResponse(msg proto.Message, err error) error {
 	if err != nil {
 		// check, if it is a gRPC error
 		s, ok := status.FromError(err)
@@ -177,6 +179,7 @@ func PromptForLogin() (loginRequest *auth.LoginRequest, err error) {
 
 	fmt.Print("Enter username: ")
 	username, err := reader.ReadString('\n')
+	fmt.Println()
 
 	if err != nil {
 		return
@@ -218,7 +221,7 @@ func (s *Session) AuthenticatedContext(ctx context.Context) context.Context {
 		))
 }
 
-func DefaultArgsShellComp(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+func DefaultArgsShellComp(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
 	return []string{}, cobra.ShellCompDirectiveNoFileComp
 }
 


Test patch:
diff --git a/api/assessment/assessment_test.go b/api/assessment/assessment_test.go
index 943c642f..5e70af57 100644
--- a/api/assessment/assessment_test.go
+++ b/api/assessment/assessment_test.go
@@ -26,11 +26,12 @@
 package assessment
 
 import (
+	"reflect"
+	"testing"
+
 	"github.com/stretchr/testify/assert"
 	"google.golang.org/protobuf/types/known/structpb"
 	"google.golang.org/protobuf/types/known/timestamppb"
-	"reflect"
-	"testing"
 )
 
 func Test_ValidateAssessmentResult(t *testing.T) {
@@ -38,6 +39,8 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 		AssessmentResult *AssessmentResult
 	}
 
+	const assessmentResultID = "11111111-1111-1111-1111-111111111111"
+	const mockEvidenceID = "11111111-1111-1111-1111-111111111111"
 	tests := []struct {
 		name          string
 		args          args
@@ -45,10 +48,80 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 		wantRespError error
 		wantErr       bool
 	}{
+		{
+			name: "Missing assessment result id",
+			args: args{
+				&AssessmentResult{
+					// Empty id
+					Id:       "",
+					MetricId: "MockMetricID",
+					MetricConfiguration: &MetricConfiguration{
+						Operator: "MockOperator",
+						TargetValue: &structpb.Value{
+							Kind: &structpb.Value_StringValue{
+								StringValue: "MockTargetValue",
+							},
+						},
+					},
+					EvidenceId: mockEvidenceID,
+				},
+			},
+			wantResp: "",
+			// cannot access unexported invalidLengthError of uuid package. Use the error string directly
+			wantRespError: ErrIdInvalidFormat,
+			wantErr:       true,
+		},
+		{
+			name: "Wrong length of assessment result id",
+			args: args{
+				&AssessmentResult{
+					// Only 4 characters
+					Id:       "1234",
+					MetricId: "MockMetricID",
+					MetricConfiguration: &MetricConfiguration{
+						Operator: "MockOperator",
+						TargetValue: &structpb.Value{
+							Kind: &structpb.Value_StringValue{
+								StringValue: "MockTargetValue",
+							},
+						},
+					},
+					EvidenceId: mockEvidenceID,
+				},
+			},
+			wantResp: "",
+			// cannot access unexported invalidLengthError of uuid package. Use the error string directly
+			wantRespError: ErrIdInvalidFormat,
+			wantErr:       true,
+		},
+		{
+			name: "Wrong format of assessment result id",
+			args: args{
+				&AssessmentResult{
+					// Wrong format: 'x' not allowed (no hexadecimal character)
+					Id:       "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
+					MetricId: "MockMetricID",
+					MetricConfiguration: &MetricConfiguration{
+						Operator: "MockOperator",
+						TargetValue: &structpb.Value{
+							Kind: &structpb.Value_StringValue{
+								StringValue: "MockTargetValue",
+							},
+						},
+					},
+					EvidenceId: mockEvidenceID,
+				},
+			},
+			wantResp: "",
+			// Copied error of uuid package.
+			wantRespError: ErrIdInvalidFormat,
+			wantErr:       true,
+		},
 		{
 			name: "Missing assessment result timestamp",
 			args: args{
 				&AssessmentResult{
+					Id:       assessmentResultID,
 					MetricId: "MockMetricID",
 					MetricConfiguration: &MetricConfiguration{
 						Operator: "MockOperator",
@@ -58,7 +131,7 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 							},
 						},
 					},
-					EvidenceId: "MockEvidenceID",
+					EvidenceId: mockEvidenceID,
 				},
 			},
 			wantResp:      "",
@@ -69,6 +142,7 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 			name: "Missing assessment result metric id",
 			args: args{
 				&AssessmentResult{
+					Id:        assessmentResultID,
 					Timestamp: timestamppb.Now(),
 					MetricConfiguration: &MetricConfiguration{
 						Operator: "MockOperator",
@@ -78,7 +152,7 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 							},
 						},
 					},
-					EvidenceId: "MockEvidenceID",
+					EvidenceId: mockEvidenceID,
 				},
 			},
 			wantResp:      "",
@@ -89,9 +163,10 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 			name: "Missing assessment result metric configuration",
 			args: args{
 				&AssessmentResult{
+					Id:         assessmentResultID,
 					Timestamp:  timestamppb.Now(),
 					MetricId:   "MockMetricID",
-					EvidenceId: "MockEvidenceID",
+					EvidenceId: mockEvidenceID,
 				},
 			},
 			wantResp:      "",
@@ -102,6 +177,7 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 			name: "Missing assessment result metric configuration operator",
 			args: args{
 				&AssessmentResult{
+					Id:        assessmentResultID,
 					Timestamp: timestamppb.Now(),
 					MetricId:  "MockMetricID",
 					MetricConfiguration: &MetricConfiguration{
@@ -111,7 +187,7 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 							},
 						},
 					},
-					EvidenceId: "MockEvidenceID",
+					EvidenceId: mockEvidenceID,
 				},
 			},
 			wantResp:      "",
@@ -122,12 +198,13 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 			name: "Missing assessment result metric configuration target value",
 			args: args{
 				&AssessmentResult{
+					Id:        assessmentResultID,
 					Timestamp: timestamppb.Now(),
 					MetricId:  "MockMetricID",
 					MetricConfiguration: &MetricConfiguration{
 						Operator: "MockOperator",
 					},
-					EvidenceId: "MockEvidenceID",
+					EvidenceId: mockEvidenceID,
 				},
 			},
 			wantResp:      "",
@@ -138,6 +215,7 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 			name: "Missing assessment result evidence id",
 			args: args{
 				&AssessmentResult{
+					Id:        assessmentResultID,
 					Timestamp: timestamppb.Now(),
 					MetricId:  "MockMetricID",
 					MetricConfiguration: &MetricConfiguration{
@@ -151,13 +229,14 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 				},
 			},
 			wantResp:      "",
-			wantRespError: ErrEvidenceIdMissing,
+			wantRespError: ErrEvidenceIdInvalidFormat,
 			wantErr:       true,
 		},
 		{
 			name: "Valid assessment result",
 			args: args{
 				&AssessmentResult{
+					Id:        assessmentResultID,
 					Timestamp: timestamppb.Now(),
 					MetricId:  "MockMetricID",
 					MetricConfiguration: &MetricConfiguration{
@@ -168,7 +247,8 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 							},
 						},
 					},
-					EvidenceId: "MockEvidenceID",
+					EvidenceId: mockEvidenceID,
+					ResourceId: "myResource",
 				},
 			},
 			wantResp:      "",
@@ -191,7 +271,7 @@ func Test_ValidateAssessmentResult(t *testing.T) {
 			assert.Equal(t, resourceId, tt.wantResp)
 
 			if err != nil {
-				assert.Equal(t, tt.wantRespError.Error(), err.Error())
+				assert.ErrorIs(t, err, tt.wantRespError)
 			}
 		})
 	}
diff --git a/cli/commands/assessmentresult/assessment_result_test.go b/cli/commands/assessmentresult/assessment_result_test.go
index ce0b153d..d9d9ff9e 100644
--- a/cli/commands/assessmentresult/assessment_result_test.go
+++ b/cli/commands/assessmentresult/assessment_result_test.go
@@ -27,6 +27,14 @@ package assessmentresult
 
 import (
 	"bytes"
+	"context"
+	"encoding/json"
+	"fmt"
+	"io/ioutil"
+	"net"
+	"os"
+	"testing"
+
 	"clouditor.io/clouditor/api/assessment"
 	"clouditor.io/clouditor/api/orchestrator"
 	"clouditor.io/clouditor/cli"
@@ -34,19 +42,12 @@ import (
 	"clouditor.io/clouditor/persistence"
 	service_auth "clouditor.io/clouditor/service/auth"
 	service_orchestrator "clouditor.io/clouditor/service/orchestrator"
-	"context"
-	"encoding/json"
-	"fmt"
 	"github.com/spf13/viper"
 	"github.com/stretchr/testify/assert"
 	"google.golang.org/grpc"
 	"google.golang.org/protobuf/encoding/protojson"
 	"google.golang.org/protobuf/types/known/structpb"
 	"google.golang.org/protobuf/types/known/timestamppb"
-	"io/ioutil"
-	"net"
-	"os"
-	"testing"
 )
 
 var sock net.Listener
@@ -79,10 +80,11 @@ func TestMain(m *testing.M) {
 	orchestrator.RegisterOrchestratorServer(server, service)
 	_, err = service.StoreAssessmentResult(context.TODO(), &orchestrator.StoreAssessmentResultRequest{
 		Result: &assessment.AssessmentResult{
-			Id:         "assessmentResultID",
+			Id:         "11111111-1111-1111-1111-111111111111",
 			MetricId:   "assessmentResultMetricID",
-			EvidenceId: "evidenceID",
+			EvidenceId: "11111111-1111-1111-1111-111111111111",
 			Timestamp:  timestamppb.Now(),
+			ResourceId: "myResource",
 			MetricConfiguration: &assessment.MetricConfiguration{
 				TargetValue: toStruct(1.0),
 				Operator:    "operator",
diff --git a/cli/commands/service/orchestrator/orchestrator_test.go b/cli/commands/service/orchestrator/orchestrator_test.go
index 46148879..724aeb35 100644
--- a/cli/commands/service/orchestrator/orchestrator_test.go
+++ b/cli/commands/service/orchestrator/orchestrator_test.go
@@ -27,6 +27,14 @@ package orchestrator
 
 import (
 	"bytes"
+	"context"
+	"encoding/json"
+	"fmt"
+	"io/ioutil"
+	"net"
+	"os"
+	"testing"
+
 	"clouditor.io/clouditor/api/assessment"
 	"clouditor.io/clouditor/api/orchestrator"
 	"clouditor.io/clouditor/cli"
@@ -34,19 +42,12 @@ import (
 	"clouditor.io/clouditor/persistence"
 	service_auth "clouditor.io/clouditor/service/auth"
 	service_orchestrator "clouditor.io/clouditor/service/orchestrator"
-	"context"
-	"encoding/json"
-	"fmt"
 	"github.com/spf13/viper"
 	"github.com/stretchr/testify/assert"
 	"google.golang.org/grpc"
 	"google.golang.org/protobuf/encoding/protojson"
 	"google.golang.org/protobuf/types/known/structpb"
 	"google.golang.org/protobuf/types/known/timestamppb"
-	"io/ioutil"
-	"net"
-	"os"
-	"testing"
 )
 
 var sock net.Listener
@@ -79,10 +80,11 @@ func TestMain(m *testing.M) {
 	// Store an assessment result that output of CMD 'list_results' is not empty
 	_, err = service.StoreAssessmentResult(context.TODO(), &orchestrator.StoreAssessmentResultRequest{
 		Result: &assessment.AssessmentResult{
-			Id:         "assessmentResultID",
+			Id:         "11111111-1111-1111-1111-111111111111",
 			MetricId:   "assessmentResultMetricID",
-			EvidenceId: "evidenceID",
+			EvidenceId: "11111111-1111-1111-1111-111111111111",
 			Timestamp:  timestamppb.Now(),
+			ResourceId: "myResource",
 			MetricConfiguration: &assessment.MetricConfiguration{
 				TargetValue: toStruct(1.0),
 				Operator:    "operator",
diff --git a/service/assessment/assessment_test.go b/service/assessment/assessment_test.go
index 7ed44d55..c6e34f28 100644
--- a/service/assessment/assessment_test.go
+++ b/service/assessment/assessment_test.go
@@ -26,15 +26,23 @@
 package assessment
 
 import (
+	"context"
+	"encoding/json"
+	"fmt"
+	"io"
+	"net"
+	"os"
+	"reflect"
+	"runtime"
+	"testing"
+	"time"
+
 	"clouditor.io/clouditor/api/assessment"
 	"clouditor.io/clouditor/api/evidence"
 	"clouditor.io/clouditor/api/orchestrator"
 	service_evidenceStore "clouditor.io/clouditor/service/evidence"
 	service_orchestrator "clouditor.io/clouditor/service/orchestrator"
 	"clouditor.io/clouditor/voc"
-	"context"
-	"encoding/json"
-	"fmt"
 	"github.com/stretchr/testify/assert"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/codes"
@@ -45,13 +53,6 @@ import (
 	"google.golang.org/protobuf/types/known/emptypb"
 	"google.golang.org/protobuf/types/known/structpb"
 	"google.golang.org/protobuf/types/known/timestamppb"
-	"io"
-	"net"
-	"os"
-	"reflect"
-	"runtime"
-	"testing"
-	"time"
 )
 
 var lis *bufconn.Listener
@@ -255,7 +256,7 @@ func TestAssessEvidences(t *testing.T) {
 				results:          make(map[string]*assessment.AssessmentResult)},
 			args: args{stream: &mockAssessmentStream{
 				evidence: &evidence.Evidence{
-					Id:        "MockEvidenceId",
+					Id:        "11111111-1111-1111-1111-111111111111",
 					ToolId:    "mock",
 					Timestamp: timestamppb.Now(),
 					Resource:  toStruct(voc.VirtualMachine{Compute: &voc.Compute{CloudResource: &voc.CloudResource{ID: "my-resource-id", Type: []string{"VirtualMachine"}}}}, t),
@@ -333,7 +334,7 @@ func TestAssessmentResultHooks(t *testing.T) {
 				in0: context.TODO(),
 				evidence: &assessment.AssessEvidenceRequest{
 					Evidence: &evidence.Evidence{
-						Id:        "MockEvidenceID",
+						Id:        "11111111-1111-1111-1111-111111111111",
 						ToolId:    "mock",
 						Timestamp: timestamppb.Now(),
 						Resource: toStruct(voc.VirtualMachine{
@@ -392,7 +393,7 @@ func TestListAssessmentResults(t *testing.T) {
 	assert.NoError(t, s.mockOrchestratorStream())
 	_, err := s.AssessEvidence(context.TODO(), &assessment.AssessEvidenceRequest{
 		Evidence: &evidence.Evidence{
-			Id:        "mockEvidenceId",
+			Id:        "11111111-1111-1111-1111-111111111111",
 			ToolId:    "mock",
 			Timestamp: timestamppb.Now(),
 			Resource:  toStruct(voc.VirtualMachine{Compute: &voc.Compute{CloudResource: &voc.CloudResource{ID: "my-resource-id", Type: []string{"VirtualMachine"}}}}, t),
@@ -634,7 +635,7 @@ func TestHandleEvidence(t *testing.T) {
 			},
 			args: args{
 				evidence: &evidence.Evidence{
-					Id:        "mockEvidenceId",
+					Id:        "11111111-1111-1111-1111-111111111111",
 					ToolId:    "mock",
 					Timestamp: timestamppb.Now(),
 					Resource:  toStruct(voc.VirtualMachine{Compute: &voc.Compute{CloudResource: &voc.CloudResource{ID: "my-resource-id", Type: []string{"VirtualMachine"}}}}, t),
@@ -654,7 +655,7 @@ func TestHandleEvidence(t *testing.T) {
 			},
 			args: args{
 				evidence: &evidence.Evidence{
-					Id:        "mockEvidenceId",
+					Id:        "11111111-1111-1111-1111-111111111111",
 					ToolId:    "mock",
 					Timestamp: timestamppb.Now(),
 					Resource:  toStruct(voc.VirtualMachine{Compute: &voc.Compute{CloudResource: &voc.CloudResource{ID: "my-resource-id", Type: []string{}}}}, t),
diff --git a/service/orchestrator/orchestrator_test.go b/service/orchestrator/orchestrator_test.go
index 1c109cfd..511496eb 100644
--- a/service/orchestrator/orchestrator_test.go
+++ b/service/orchestrator/orchestrator_test.go
@@ -27,19 +27,20 @@ package orchestrator
 
 import (
 	"context"
-	"google.golang.org/grpc/metadata"
-	"google.golang.org/protobuf/types/known/emptypb"
-	"google.golang.org/protobuf/types/known/structpb"
-	"google.golang.org/protobuf/types/known/timestamppb"
 	"io"
 	"io/fs"
-	"k8s.io/apimachinery/pkg/util/json"
 	"os"
 	"reflect"
 	"runtime"
 	"testing"
 	"time"
 
+	"google.golang.org/grpc/metadata"
+	"google.golang.org/protobuf/types/known/emptypb"
+	"google.golang.org/protobuf/types/known/structpb"
+	"google.golang.org/protobuf/types/known/timestamppb"
+	"k8s.io/apimachinery/pkg/util/json"
+
 	"clouditor.io/clouditor/api/assessment"
 	"clouditor.io/clouditor/persistence"
 
@@ -50,6 +51,9 @@ import (
 var service *Service
 var defaultTarget *orchestrator.CloudService
 
+const assessmentResultID1 = "11111111-1111-1111-1111-111111111111"
+const assessmentResultID2 = "11111111-1111-1111-1111-111111111112"
+
 func TestMain(m *testing.M) {
 	err := os.Chdir("../../")
 	if err != nil {
@@ -120,9 +124,9 @@ func TestAssessmentResultHook(t *testing.T) {
 				in0: context.TODO(),
 				assessment: &orchestrator.StoreAssessmentResultRequest{
 					Result: &assessment.AssessmentResult{
-						Id:         "assessmentResultID",
+						Id:         assessmentResultID1,
 						MetricId:   "assessmentResultMetricID",
-						EvidenceId: "evidenceID",
+						EvidenceId: "11111111-1111-1111-1111-111111111111",
 						Timestamp:  timestamppb.Now(),
 						MetricConfiguration: &assessment.MetricConfiguration{
 							TargetValue: toStruct(1.0),
@@ -232,9 +236,9 @@ func TestStoreAssessmentResult(t *testing.T) {
 				in0: context.TODO(),
 				assessment: &orchestrator.StoreAssessmentResultRequest{
 					Result: &assessment.AssessmentResult{
-						Id:         "assessmentResultID",
+						Id:         assessmentResultID1,
 						MetricId:   "assessmentResultMetricID",
-						EvidenceId: "evidenceID",
+						EvidenceId: "11111111-1111-1111-1111-111111111111",
 						Timestamp:  timestamppb.Now(),
 						MetricConfiguration: &assessment.MetricConfiguration{
 							TargetValue: toStruct(1.0),
@@ -256,8 +260,8 @@ func TestStoreAssessmentResult(t *testing.T) {
 				in0: context.TODO(),
 				assessment: &orchestrator.StoreAssessmentResultRequest{
 					Result: &assessment.AssessmentResult{
-						Id:         "assessmentResultID",
-						EvidenceId: "evidenceID",
+						Id:         assessmentResultID1,
+						EvidenceId: "11111111-1111-1111-1111-111111111111",
 						Timestamp:  timestamppb.Now(),
 						MetricConfiguration: &assessment.MetricConfiguration{
 							TargetValue: toStruct(1.0),
@@ -288,7 +292,7 @@ func TestStoreAssessmentResult(t *testing.T) {
 			}
 
 			if err == nil {
-				assert.NotNil(t, s.results["assessmentResultID"])
+				assert.NotNil(t, s.results[assessmentResultID1])
 			} else {
 				assert.Empty(t, s.results)
 			}
@@ -346,9 +350,9 @@ func (m *mockStreamer) Recv() (*assessment.AssessmentResult, error) {
 	if m.counter == 0 {
 		m.counter++
 		return &assessment.AssessmentResult{
-			Id:         "assessmentResultID",
+			Id:         assessmentResultID1,
 			MetricId:   "assessmentResultMetricID",
-			EvidenceId: "evidenceID",
+			EvidenceId: "11111111-1111-1111-1111-111111111111",
 			Timestamp:  timestamppb.Now(),
 			MetricConfiguration: &assessment.MetricConfiguration{
 				TargetValue: toStruct(1.0),
@@ -362,9 +366,9 @@ func (m *mockStreamer) Recv() (*assessment.AssessmentResult, error) {
 	} else if m.counter == 1 {
 		m.counter++
 		return &assessment.AssessmentResult{
-			Id:         "assessmentResultID2",
+			Id:         assessmentResultID2,
 			MetricId:   "assessmentResultMetricID2",
-			EvidenceId: "evidenceID2",
+			EvidenceId: "11111111-1111-1111-1111-111111111112",
 			Timestamp:  timestamppb.Now(),
 			MetricConfiguration: &assessment.MetricConfiguration{
 				TargetValue: toStruct(1.0),