diff --git a/audit/api/api_common.go b/audit/api/api_common.go index 40991ef..18a1f55 100644 --- a/audit/api/api_common.go +++ b/audit/api/api_common.go @@ -16,6 +16,7 @@ import ( // ContentTypeCloudEventsProtobuf the cloudevents protobuf content-type sent in metadata of messages const ContentTypeCloudEventsProtobuf = "application/cloudevents+protobuf" +const ContentTypeCloudEventsJson = "application/cloudevents+json; charset=UTF-8" // ErrUnknownPluralType indicates that the given input is an unknown plural type var ErrUnknownPluralType = errors.New("unknown plural type") diff --git a/audit/api/api_legacy.go b/audit/api/api_legacy.go index 41c120e..e14c614 100644 --- a/audit/api/api_legacy.go +++ b/audit/api/api_legacy.go @@ -2,11 +2,9 @@ package api import ( "context" - "errors" - "fmt" - "dev.azure.com/schwarzit/schwarzit.stackit-core-platform/audit-go.git/audit/messaging" auditV1 "dev.azure.com/schwarzit/schwarzit.stackit-core-platform/audit-go.git/gen/go/audit/v1" + "errors" "google.golang.org/protobuf/proto" ) @@ -136,8 +134,8 @@ func (a *LegacyAuditApi) ValidateAndSerializeWithTrace( Source: event.ProtoPayload.ServiceName, Id: event.InsertId, Time: event.ProtoPayload.RequestMetadata.RequestAttributes.Time.AsTime(), - DataContentType: ContentTypeCloudEventsProtobuf, - DataType: fmt.Sprintf("%v", routableEvent.ProtoReflect().Descriptor().FullName()), + DataContentType: ContentTypeCloudEventsJson, + DataType: "audit.v1.LegacyAuditEvent", Subject: event.ProtoPayload.ResourceName, Data: legacyBytes, TraceParent: traceParent, diff --git a/audit/api/api_legacy_dynamic.go b/audit/api/api_legacy_dynamic.go index c19f61a..9959a70 100644 --- a/audit/api/api_legacy_dynamic.go +++ b/audit/api/api_legacy_dynamic.go @@ -119,8 +119,8 @@ func (a *DynamicLegacyAuditApi) ValidateAndSerializeWithTrace( Source: event.ProtoPayload.ServiceName, Id: event.InsertId, Time: event.ProtoPayload.RequestMetadata.RequestAttributes.Time.AsTime(), - DataContentType: ContentTypeCloudEventsProtobuf, - DataType: fmt.Sprintf("%v", routableEvent.ProtoReflect().Descriptor().FullName()), + DataContentType: ContentTypeCloudEventsJson, + DataType: "audit.v1.LegacyAuditEvent", Subject: event.ProtoPayload.ResourceName, Data: legacyBytes, TraceParent: traceParent, diff --git a/audit/api/api_legacy_test.go b/audit/api/api_legacy_test.go index 506a6cc..7b34cf2 100644 --- a/audit/api/api_legacy_test.go +++ b/audit/api/api_legacy_test.go @@ -441,6 +441,8 @@ func validateSentMessageWithDetails( // Check topic name assert.Equal(t, topicName, *message.Properties.To) + assert.Equal(t, ContentTypeCloudEventsJson, message.ApplicationProperties["cloudEvents:datacontenttype"]) + assert.Equal(t, "audit.v1.LegacyAuditEvent", message.ApplicationProperties["cloudEvents:type"]) assert.Equal(t, *traceParent, message.ApplicationProperties["cloudEvents:traceparent"]) assert.Equal(t, *traceState, message.ApplicationProperties["cloudEvents:tracestate"])