@@ -17,6 +17,7 @@ func makePolicyControlNetworkSlice(mcc, mnc, sst, sd string, filteringRules []co
1717 Mcc : mcc ,
1818 Mnc : mnc ,
1919 }
20+ deviceGroups := []string {"testDG" }
2021 siteInfo := configmodels.SliceSiteInfo {
2122 SiteName : "test" ,
2223 Plmn : plmnId ,
@@ -28,6 +29,7 @@ func makePolicyControlNetworkSlice(mcc, mnc, sst, sd string, filteringRules []co
2829 }
2930 networkSlice := configmodels.Slice {
3031 SliceName : "slice1" ,
32+ SiteDeviceGroup : deviceGroups ,
3133 SiteInfo : siteInfo ,
3234 SliceId : sliceId ,
3335 ApplicationFilteringRules : filteringRules ,
@@ -36,13 +38,23 @@ func makePolicyControlNetworkSlice(mcc, mnc, sst, sd string, filteringRules []co
3638}
3739
3840var (
39- testSst int32 = 1
40- testSd = "12345"
41- testRuleName = "TestRule"
42- testRulePriority int32 = 12
43- testRuleQci int32 = 12
44- testRuleArp int32 = 100
45- validSliceApplicationFilteringRule = configmodels.SliceApplicationFilteringRules {
41+ testSst int32 = 1
42+ testSd = "12345"
43+ testRuleName = "TestRule"
44+ testRulePriority int32 = 12
45+ testRuleQci int32 = 12
46+ testRuleArp int32 = 100
47+ testDeviceGroupName = "testDG"
48+ testDnnName = "testDnn"
49+ testDG = configmodels.DeviceGroups {
50+ DeviceGroupName : testDeviceGroupName ,
51+ Imsis : []string {"001010123456789" },
52+ IpDomainExpanded : configmodels.DeviceGroupsIpDomainExpanded {
53+ Dnn : testDnnName ,
54+ },
55+ }
56+ testDeviceGroups = map [string ]configmodels.DeviceGroups {testDeviceGroupName : testDG }
57+ validSliceApplicationFilteringRule = configmodels.SliceApplicationFilteringRules {
4658 RuleName : testRuleName ,
4759 Priority : testRulePriority ,
4860 Action : "allow" ,
@@ -64,17 +76,20 @@ func TestSyncPolicyControl(t *testing.T) {
6476 tests := []struct {
6577 name string
6678 networkSlices []configmodels.Slice
79+ deviceGroups map [string ]configmodels.DeviceGroups
6780 expectedResponse []nfConfigApi.PolicyControl
6881 }{
6982 {
7083 name : "Network Slice with valid SliceApplicationFilteringRules produces valid Policy Control config" ,
7184 networkSlices : []configmodels.Slice {
7285 makePolicyControlNetworkSlice ("001" , "01" , fmt .Sprintf ("%d" , testSst ), testSd , []configmodels.SliceApplicationFilteringRules {validSliceApplicationFilteringRule }),
7386 },
87+ deviceGroups : testDeviceGroups ,
7488 expectedResponse : []nfConfigApi.PolicyControl {
7589 {
7690 PlmnId : * nfConfigApi .NewPlmnId ("001" , "01" ),
7791 Snssai : makeSnssaiWithSd (testSst , testSd ),
92+ Dnns : []string {testDnnName },
7893 PccRules : []nfConfigApi.PccRule {
7994 {
8095 RuleId : testRuleName ,
@@ -106,10 +121,12 @@ func TestSyncPolicyControl(t *testing.T) {
106121 networkSlices : []configmodels.Slice {
107122 makePolicyControlNetworkSlice ("001" , "01" , fmt .Sprintf ("%d" , testSst ), testSd , []configmodels.SliceApplicationFilteringRules {}),
108123 },
124+ deviceGroups : testDeviceGroups ,
109125 expectedResponse : []nfConfigApi.PolicyControl {
110126 {
111127 PlmnId : * nfConfigApi .NewPlmnId ("001" , "01" ),
112128 Snssai : makeSnssaiWithSd (testSst , testSd ),
129+ Dnns : []string {testDnnName },
113130 PccRules : []nfConfigApi.PccRule {* defaultPccRule },
114131 },
115132 },
@@ -119,10 +136,12 @@ func TestSyncPolicyControl(t *testing.T) {
119136 networkSlices : []configmodels.Slice {
120137 makePolicyControlNetworkSlice ("001" , "01" , fmt .Sprintf ("%d" , testSst ), testSd , []configmodels.SliceApplicationFilteringRules {}),
121138 },
139+ deviceGroups : testDeviceGroups ,
122140 expectedResponse : []nfConfigApi.PolicyControl {
123141 {
124142 PlmnId : * nfConfigApi .NewPlmnId ("001" , "01" ),
125143 Snssai : makeSnssaiWithSd (testSst , testSd ),
144+ Dnns : []string {testDnnName },
126145 PccRules : []nfConfigApi.PccRule {* defaultPccRule },
127146 },
128147 },
@@ -132,14 +151,30 @@ func TestSyncPolicyControl(t *testing.T) {
132151 networkSlices : []configmodels.Slice {
133152 makePolicyControlNetworkSlice ("999" , "99" , "a" , testSd , []configmodels.SliceApplicationFilteringRules {}),
134153 },
154+ deviceGroups : testDeviceGroups ,
135155 expectedResponse : []nfConfigApi.PolicyControl {},
136156 },
157+ {
158+ name : "Network Slice with non-existent Device Group returns empty DNNs in Policy Control" ,
159+ networkSlices : []configmodels.Slice {
160+ makePolicyControlNetworkSlice ("001" , "01" , fmt .Sprintf ("%d" , testSst ), testSd , []configmodels.SliceApplicationFilteringRules {}),
161+ },
162+ deviceGroups : map [string ]configmodels.DeviceGroups {},
163+ expectedResponse : []nfConfigApi.PolicyControl {
164+ {
165+ PlmnId : * nfConfigApi .NewPlmnId ("001" , "01" ),
166+ Snssai : makeSnssaiWithSd (testSst , testSd ),
167+ Dnns : []string {},
168+ PccRules : []nfConfigApi.PccRule {* defaultPccRule },
169+ },
170+ },
171+ },
137172 }
138173
139174 for _ , tt := range tests {
140175 t .Run (tt .name , func (t * testing.T ) {
141176 cfg := inMemoryConfig {}
142- cfg .syncPolicyControl (tt .networkSlices )
177+ cfg .syncPolicyControl (tt .networkSlices , tt . deviceGroups )
143178
144179 if ! reflect .DeepEqual (cfg .policyControl , tt .expectedResponse ) {
145180 t .Errorf ("expected %+v, got %+v" , tt .expectedResponse , cfg .policyControl )
0 commit comments