Skip to content

Commit

Permalink
Merge pull request free5gc#114 from pf-lin/fix/qos-empty
Browse files Browse the repository at this point in the history
fix: PDU Session Modification Request message does not have the IE for QoSRules or QoSFlowDescs
  • Loading branch information
ianchen0119 authored Jul 31, 2024
2 parents 85c084a + 93f56a1 commit 65bc752
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/sbi/consumer/pcf_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ func (s *npcfService) SendSMPolicyAssociationUpdateByUERequestModification(
}

// UE SHOULD only create ONE QoS Flow in a request (TS 24.501 6.4.2.2)
if len(qosRules) == 0 {
return nil, errors.New("QoS Rule not found")
}
if len(qosFlowDescs) == 0 {
return nil, errors.New("QoS Flow Description not found")
}

rule := qosRules[0]
flowDesc := qosFlowDescs[0]

Expand Down
78 changes: 78 additions & 0 deletions internal/sbi/consumer/pcf_service_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package consumer_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"

"github.com/free5gc/nas/nasType"
"github.com/free5gc/openapi/models"
smf_context "github.com/free5gc/smf/internal/context"
"github.com/free5gc/smf/internal/sbi/consumer"
"github.com/free5gc/smf/pkg/factory"
"github.com/free5gc/smf/pkg/service"
)

var testConfig = factory.Config{
Info: &factory.Info{
Version: "1.0.0",
Description: "SMF procdeure test configuration",
},
Configuration: &factory.Configuration{
Sbi: &factory.Sbi{
Scheme: "http",
RegisterIPv4: "127.0.0.1",
BindingIPv4: "127.0.0.1",
Port: 8000,
},
},
}

func TestSendSMPolicyAssociationUpdateByUERequestModification(t *testing.T) {
smf_context.InitSmfContext(&testConfig)

testCases := []struct {
name string
smContext *smf_context.SMContext
qosRules nasType.QoSRules
qosFlowDescs nasType.QoSFlowDescs

smPolicyDecision *models.SmPolicyDecision
responseErr error
}{
{
name: "QoSRules is nil",
smContext: smf_context.NewSMContext("imsi-208930000000001", 10),
qosRules: nasType.QoSRules{},
qosFlowDescs: nasType.QoSFlowDescs{nasType.QoSFlowDesc{}},
smPolicyDecision: nil,
responseErr: fmt.Errorf("QoS Rule not found"),
},
{
name: "QoSFlowDescs is nil",
smContext: smf_context.NewSMContext("imsi-208930000000001", 10),
qosRules: nasType.QoSRules{nasType.QoSRule{}},
qosFlowDescs: nasType.QoSFlowDescs{},
smPolicyDecision: nil,
responseErr: fmt.Errorf("QoS Flow Description not found"),
},
}

mockSmf := service.NewMockSmfAppInterface(gomock.NewController(t))
consumer, errNewConsumer := consumer.NewConsumer(mockSmf)
if errNewConsumer != nil {
t.Fatalf("Failed to create consumer: %+v", errNewConsumer)
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
smPolicyDecision, err := consumer.SendSMPolicyAssociationUpdateByUERequestModification(
tc.smContext, tc.qosRules, tc.qosFlowDescs)

require.Equal(t, tc.smPolicyDecision, smPolicyDecision)
require.Equal(t, tc.responseErr.Error(), err.Error())
})
}
}

0 comments on commit 65bc752

Please sign in to comment.