@@ -40,7 +40,7 @@ func TestDecodeFiretailRecordWithMissingPart(t *testing.T) {
4040 assert .Equal (t , "record had 2 parts when split by ':'" , err .Error ())
4141}
4242
43- func TestDecodeFiretailRecordWithExtraPart (t * testing.T ) {
43+ func TestDecodeFiretailRecordWithExtraPartSuffixed (t * testing.T ) {
4444 testRecord := firetail.Record {
4545 Response : firetail.RecordResponse {
4646 StatusCode : 200 ,
@@ -56,7 +56,25 @@ func TestDecodeFiretailRecordWithExtraPart(t *testing.T) {
5656 assert .Nil (t , decodedRecord )
5757 require .NotNil (t , err )
5858
59- assert .Equal (t , "record had 4 parts when split by ':'" , err .Error ())
59+ assert .Equal (t , "record did not have firetail prefix" , err .Error ())
60+ }
61+
62+ func TestDecodeFiretailRecordWithExtraPartPrefixed (t * testing.T ) {
63+ testRecord := firetail.Record {
64+ Response : firetail.RecordResponse {
65+ StatusCode : 200 ,
66+ Body : "Test Body" ,
67+ },
68+ }
69+ testPayloadBytes , err := json .Marshal (testRecord )
70+ require .Nil (t , err )
71+
72+ encodedRecord := "extra:firetail:log-ext:" + base64 .StdEncoding .EncodeToString (testPayloadBytes ) + ""
73+
74+ decodedRecord , err := decodeFiretailRecord (encodedRecord )
75+ require .Nil (t , err )
76+
77+ assert .Equal (t , testRecord .Response , * & decodedRecord .Response )
6078}
6179
6280func TestDecodeFiretailRecordWithInvalidPrefix (t * testing.T ) {
@@ -78,6 +96,24 @@ func TestDecodeFiretailRecordWithInvalidPrefix(t *testing.T) {
7896 assert .Equal (t , "record did not have firetail prefix" , err .Error ())
7997}
8098
99+ func TestDecodeFiretailRecordWithTimestampPrefix (t * testing.T ) {
100+ testRecord := firetail.Record {
101+ Response : firetail.RecordResponse {
102+ StatusCode : 200 ,
103+ Body : "Test Body" ,
104+ },
105+ }
106+ testPayloadBytes , err := json .Marshal (testRecord )
107+ require .Nil (t , err )
108+
109+ encodedRecord := "2023-02-09T14:12:59.574Z 7b9025e7-228f-4f39-ab16-1cadba2bb3f6 INFO firetail:log-ext:" + base64 .StdEncoding .EncodeToString (testPayloadBytes )
110+
111+ decodedRecord , err := decodeFiretailRecord (encodedRecord )
112+ require .Nil (t , err )
113+
114+ assert .Equal (t , testRecord .Response , * & decodedRecord .Response )
115+ }
116+
81117func TestDecodeFiretailRecordWithInvalidToken (t * testing.T ) {
82118 testRecord := firetail.Record {
83119 Response : firetail.RecordResponse {
0 commit comments