@@ -28,24 +28,49 @@ var formatBasicTests = []struct {
2828 outContains string
2929}{
3030 {
31- []byte ("{ \ " ibm_datetime\" : \ " 2020/06/24 00:00:00\" , \ " message\" : \ " Hello world\" }" ),
31+ []byte (`{ "ibm_datetime": "2020/06/24 00:00:00", "message": "Hello world"}` ),
3232 "Hello" ,
3333 },
3434 {
35- []byte ("{ \ " ibm_datetime\" : \ " 2020/06/24 00:00:00\" , \ " message\" : \ " Hello world\ " , \ " ibm_commentInsert1\" : \ " foo\" }" ),
35+ []byte (`{ "ibm_datetime": "2020/06/24 00:00:00", "message": "Hello world", "ibm_commentInsert1": "foo"}` ),
3636 "CommentInsert1(foo)" ,
3737 },
3838 {
39- []byte ("{ \ " ibm_datetime\" : \ " 2020/06/24 00:00:00\" , \ " message\" : \ " Hello world\ " , \ " ibm_arithInsert1\ " :1}" ),
39+ []byte (`{ "ibm_datetime": "2020/06/24 00:00:00", "message": "Hello world", "ibm_arithInsert1":1}` ),
4040 "ArithInsert1(1)" ,
4141 },
42+ {
43+ []byte (`{
44+ "ibm_audit_eventName": "SECURITY_AUTHN",
45+ "ibm_audit_eventSequenceNumber": "47",
46+ "ibm_audit_eventTime": "2025-05-29T12:08:24.056+0000",
47+ "ibm_audit_initiator.host.address": "10.254.16.2",
48+ "ibm_audit_observer.id": "websphere: cp4i-audit-test-ibm-mq-0.qm.mq-test.svc.cluster.local:/mnt/mqm/data/web/installations/Installation1/:mqweb",
49+ "ibm_audit_observer.name": "SecurityService",
50+ "ibm_audit_outcome": "success",
51+ "ibm_audit_reason.reasonCode": "200",
52+ "ibm_audit_reason.reasonType": "HTTPS",
53+ "ibm_audit_target.credential.token": "mquser1",
54+ "ibm_audit_target.host.address": "10.254.16.109:9443",
55+ "ibm_audit_target.id": "websphere: cp4i-audit-test-ibm-mq-0.qm.mq-test.svc.cluster.local:/mnt/mqm/data/web/installations/Installation1/:mqweb",
56+ "ibm_audit_target.method": "GET",
57+ "ibm_audit_target.name": "/ibmmq/console/",
58+ "ibm_audit_target.session": "Vu5GA1hXQEyFRqmYH5mWlGS",
59+ "ibm_datetime": "2025-05-29T12:08:24.057Z",
60+ "type": "liberty_audit"
61+ }` ),
62+ `AUDIT: eventName="SECURITY_AUTHN" eventSequenceNumber="47" outcome="success" reason.reasonCode="200" reason.reasonType="HTTPS" observer.id="websphere: cp4i-audit-test-ibm-mq-0.qm.mq-test.svc.cluster.local:/mnt/mqm/data/web/installations/Installation1/:mqweb" observer.name="SecurityService" initiator.host.address="10.254.16.2" target.id="websphere: cp4i-audit-test-ibm-mq-0.qm.mq-test.svc.cluster.local:/mnt/mqm/data/web/installations/Installation1/:mqweb" target.host.address="10.254.16.109:9443" target.credential.token="mquser1" target.method="GET" target.name="/ibmmq/console/" target.session="Vu5GA1hXQEyFRqmYH5mWlGS" eventTime="2025-05-29T12:08:24.056+0000"` ,
63+ },
4264}
4365
4466func TestFormatBasic (t * testing.T ) {
4567 for i , table := range formatBasicTests {
4668 t .Run (fmt .Sprintf ("%v" , i ), func (t * testing.T ) {
4769 var inObj map [string ]interface {}
48- json .Unmarshal (table .in , & inObj )
70+ err := json .Unmarshal (table .in , & inObj )
71+ if err != nil {
72+ t .Fatalf ("Error unmarshalling: %s" , err .Error ())
73+ }
4974 t .Logf ("Unmarshalled: %+v" , inObj )
5075 out := formatBasic (inObj )
5176 if ! strings .Contains (out , table .outContains ) {
0 commit comments