Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test code for Uncomprehended IE #8

Merged
merged 2 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
109 changes: 109 additions & 0 deletions ngap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
})
}
}