From 97f491850e8f43a6abe391035513aa7e38a02a3e Mon Sep 17 00:00:00 2001 From: Shouhei Nishi Date: Fri, 12 May 2023 17:46:17 +0900 Subject: [PATCH 1/2] Test code for Uncomprehended IE --- ngap_test.go | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/ngap_test.go b/ngap_test.go index 75be6cd..c9061dd 100644 --- a/ngap_test.go +++ b/ngap_test.go @@ -2,9 +2,12 @@ package ngap import ( "encoding/hex" + "reflect" "testing" "github.com/stretchr/testify/require" + + "github.com/free5gc/ngap/ngapType" ) func TestDecodeBackupAmfName(t *testing.T) { @@ -15,3 +18,109 @@ func TestDecodeBackupAmfName(t *testing.T) { _, err = Decoder(bs) require.NoError(t, err) } + +func TestDecoder(t *testing.T) { + type args struct { + b []byte + } + tests := []struct { + name string + args args + wantPdu *ngapType.NGAPPDU + wantErr bool + }{ + { + name: "TestUncomprehendedProcedure", + args: args{ + b: []byte{ + 0x00, 0x55, 0x00, 0x17, 0x00, 0x00, 0x02, 0x00, 0x52, 0x40, 0x06, 0x01, 0x80, 0x54, 0x45, 0x53, + 0x54, 0x00, 0x52, 0x40, 0x06, 0x01, 0x80, 0x54, 0x45, 0x53, 0x54, + }, + }, + wantPdu: &ngapType.NGAPPDU{ + Present: ngapType.NGAPPDUPresentInitiatingMessage, + InitiatingMessage: &ngapType.InitiatingMessage{ + ProcedureCode: ngapType.ProcedureCode{ + Value: 0x55, + }, + Criticality: ngapType.Criticality{ + Value: ngapType.CriticalityPresentReject, + }, + Value: ngapType.InitiatingMessageValue{ + Present: 0, + }, + }, + }, + wantErr: false, + }, + { + name: "TestUncomprehendedIE", + args: args{ + b: []byte{ + 0x00, 0x15, 0x00, 0x17, 0x00, 0x00, 0x02, 0x55, 0x55, 0x40, 0x06, 0x01, 0x80, 0x54, 0x45, 0x53, + 0x54, 0x00, 0x52, 0x40, 0x06, 0x01, 0x80, 0x54, 0x45, 0x53, 0x54, + }, + }, + wantPdu: &ngapType.NGAPPDU{ + Present: ngapType.NGAPPDUPresentInitiatingMessage, + InitiatingMessage: &ngapType.InitiatingMessage{ + ProcedureCode: ngapType.ProcedureCode{ + Value: ngapType.ProcedureCodeNGSetup, + }, + Criticality: ngapType.Criticality{ + Value: ngapType.CriticalityPresentReject, + }, + Value: ngapType.InitiatingMessageValue{ + Present: ngapType.InitiatingMessagePresentNGSetupRequest, + NGSetupRequest: &ngapType.NGSetupRequest{ + ProtocolIEs: ngapType.ProtocolIEContainerNGSetupRequestIEs{ + List: []ngapType.NGSetupRequestIEs{ + { + Id: ngapType.ProtocolIEID{ + Value: 0x5555, + }, + Criticality: ngapType.Criticality{ + Value: ngapType.CriticalityPresentIgnore, + }, + Value: ngapType.NGSetupRequestIEsValue{ + Present: 0, + }, + }, + { + Id: ngapType.ProtocolIEID{ + Value: ngapType.ProtocolIEIDRANNodeName, + }, + Criticality: ngapType.Criticality{ + Value: ngapType.CriticalityPresentIgnore, + }, + Value: ngapType.NGSetupRequestIEsValue{ + Present: ngapType.NGSetupRequestIEsPresentRANNodeName, + RANNodeName: &ngapType.RANNodeName{ + Value: "TEST", + }, + }, + }, + }, + }, + }, + }, + }, + }, + wantErr: false, + }, + } + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + gotPdu, err := Decoder(tt.args.b) + if (err != nil) != tt.wantErr { + t.Errorf("Decoder() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(gotPdu, tt.wantPdu) { + t.Errorf("Decoder() = %v, want %v", gotPdu, tt.wantPdu) + } + }) + } +} From 682848d771d5ddf87a0084f711d02578125c7dad Mon Sep 17 00:00:00 2001 From: Shouhei Nishi Date: Wed, 14 Jun 2023 12:57:33 +0900 Subject: [PATCH 2/2] update aper pkg --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 56492c6..7d8dc58 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/antonfisher/nested-logrus-formatter v1.3.1 - github.com/free5gc/aper v1.0.5-0.20230613151242-a2b93630a4ee + github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582 github.com/free5gc/openapi v1.0.6 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 diff --git a/go.sum b/go.sum index e978217..bebbd43 100644 --- a/go.sum +++ b/go.sum @@ -49,8 +49,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/free5gc/aper v1.0.5-0.20230613151242-a2b93630a4ee h1:poI3ub6RN/QN8N32/qD0uuA0cWpntGSLKnTUdGH47EE= -github.com/free5gc/aper v1.0.5-0.20230613151242-a2b93630a4ee/go.mod h1:wwL403m68CWW37lSQWIEw1NWIFrssaI1EbEjXHY8jW8= +github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582 h1:IV9PXKo6MH62e7nngSqr+cwjuoffkouPMmyX3jHC9Ds= +github.com/free5gc/aper v1.0.5-0.20230614030933-c73735898582/go.mod h1:ybHxhYnRqQ9wD4yB9r/3MZdbCYCjtqUyfLpSnJpwWd4= github.com/free5gc/openapi v1.0.6 h1:ytRjU/YZRI8UhKKyfajXSyGB6s1YDFkJ1weeAGJ8LXw= github.com/free5gc/openapi v1.0.6/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=