mirror of
https://dev.azure.com/schwarzit/schwarzit.stackit-public/_git/audit-go
synced 2026-02-08 00:57:24 +00:00
Fix data and content-type in legacy apis
This commit is contained in:
parent
6fd141e227
commit
0e6aac7370
4 changed files with 8 additions and 7 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue