mirror of
https://dev.azure.com/schwarzit/schwarzit.stackit-public/_git/audit-go
synced 2026-02-21 15:11:50 +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
|
// ContentTypeCloudEventsProtobuf the cloudevents protobuf content-type sent in metadata of messages
|
||||||
const ContentTypeCloudEventsProtobuf = "application/cloudevents+protobuf"
|
const ContentTypeCloudEventsProtobuf = "application/cloudevents+protobuf"
|
||||||
|
const ContentTypeCloudEventsJson = "application/cloudevents+json; charset=UTF-8"
|
||||||
|
|
||||||
// ErrUnknownPluralType indicates that the given input is an unknown plural type
|
// ErrUnknownPluralType indicates that the given input is an unknown plural type
|
||||||
var ErrUnknownPluralType = errors.New("unknown plural type")
|
var ErrUnknownPluralType = errors.New("unknown plural type")
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,9 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"dev.azure.com/schwarzit/schwarzit.stackit-core-platform/audit-go.git/audit/messaging"
|
"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"
|
auditV1 "dev.azure.com/schwarzit/schwarzit.stackit-core-platform/audit-go.git/gen/go/audit/v1"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
@ -136,8 +134,8 @@ func (a *LegacyAuditApi) ValidateAndSerializeWithTrace(
|
||||||
Source: event.ProtoPayload.ServiceName,
|
Source: event.ProtoPayload.ServiceName,
|
||||||
Id: event.InsertId,
|
Id: event.InsertId,
|
||||||
Time: event.ProtoPayload.RequestMetadata.RequestAttributes.Time.AsTime(),
|
Time: event.ProtoPayload.RequestMetadata.RequestAttributes.Time.AsTime(),
|
||||||
DataContentType: ContentTypeCloudEventsProtobuf,
|
DataContentType: ContentTypeCloudEventsJson,
|
||||||
DataType: fmt.Sprintf("%v", routableEvent.ProtoReflect().Descriptor().FullName()),
|
DataType: "audit.v1.LegacyAuditEvent",
|
||||||
Subject: event.ProtoPayload.ResourceName,
|
Subject: event.ProtoPayload.ResourceName,
|
||||||
Data: legacyBytes,
|
Data: legacyBytes,
|
||||||
TraceParent: traceParent,
|
TraceParent: traceParent,
|
||||||
|
|
|
||||||
|
|
@ -119,8 +119,8 @@ func (a *DynamicLegacyAuditApi) ValidateAndSerializeWithTrace(
|
||||||
Source: event.ProtoPayload.ServiceName,
|
Source: event.ProtoPayload.ServiceName,
|
||||||
Id: event.InsertId,
|
Id: event.InsertId,
|
||||||
Time: event.ProtoPayload.RequestMetadata.RequestAttributes.Time.AsTime(),
|
Time: event.ProtoPayload.RequestMetadata.RequestAttributes.Time.AsTime(),
|
||||||
DataContentType: ContentTypeCloudEventsProtobuf,
|
DataContentType: ContentTypeCloudEventsJson,
|
||||||
DataType: fmt.Sprintf("%v", routableEvent.ProtoReflect().Descriptor().FullName()),
|
DataType: "audit.v1.LegacyAuditEvent",
|
||||||
Subject: event.ProtoPayload.ResourceName,
|
Subject: event.ProtoPayload.ResourceName,
|
||||||
Data: legacyBytes,
|
Data: legacyBytes,
|
||||||
TraceParent: traceParent,
|
TraceParent: traceParent,
|
||||||
|
|
|
||||||
|
|
@ -441,6 +441,8 @@ func validateSentMessageWithDetails(
|
||||||
|
|
||||||
// Check topic name
|
// Check topic name
|
||||||
assert.Equal(t, topicName, *message.Properties.To)
|
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, *traceParent, message.ApplicationProperties["cloudEvents:traceparent"])
|
||||||
assert.Equal(t, *traceState, message.ApplicationProperties["cloudEvents:tracestate"])
|
assert.Equal(t, *traceState, message.ApplicationProperties["cloudEvents:tracestate"])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue