-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDFAB-1110] Add support for application filter (#54)
* First commit * Fix increment of internal loop * Add QER gating parameters * Refactor * Fix gate status * Fix gate status * Refactor * Allow to set gate status * Fix short command * Fix incorrect gate setting. Use app QER * Partial implementation of app filter flag * Address review comments * Address review comments * Add support for app-filter string * Address review comments * Address review comments * Add copyright header * Address review comments
- Loading branch information
1 parent
b9f0961
commit c1c9a74
Showing
8 changed files
with
172 additions
and
44 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2022-present Open Networking Foundation | ||
|
||
package pfcpsim | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/wmnsk/go-pfcp/ie" | ||
) | ||
|
||
func Test_parseAppFilter(t *testing.T) { | ||
type args struct { | ||
filterString string | ||
} | ||
|
||
type want struct { | ||
SDFFilter string | ||
gateStatus uint8 | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
args *args | ||
want *want | ||
wantErr bool | ||
}{ | ||
{name: "Correct app filter", | ||
args: &args{ | ||
filterString: "udp:10.0.0.0/8:80-80:allow", | ||
}, | ||
want: &want{ | ||
SDFFilter: "permit out udp from 10.0.0.0/8 to assigned 80-80", | ||
gateStatus: ie.GateStatusOpen, | ||
}, | ||
}, | ||
{name: "Correct app filter with deny", | ||
args: &args{ | ||
filterString: "udp:10.0.0.0/8:80-80:deny", | ||
}, | ||
want: &want{ | ||
SDFFilter: "permit out udp from 10.0.0.0/8 to assigned 80-80", | ||
gateStatus: ie.GateStatusClosed, | ||
}, | ||
}, | ||
{name: "incorrect app filter bad protocol", | ||
args: &args{ | ||
filterString: "test:10.0.0.0/8:80-80:allow", | ||
}, | ||
want: &want{}, | ||
wantErr: true, | ||
}, | ||
{name: "incorrect app filter bad IP format", | ||
args: &args{ | ||
filterString: "ip:10/8:80-80:allow", | ||
}, | ||
want: &want{}, | ||
wantErr: true, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run( | ||
tt.name, func(t *testing.T) { | ||
filter, gateStatus, err := parseAppFilter(tt.args.filterString) | ||
if tt.wantErr { | ||
require.Error(t, err) | ||
return | ||
} | ||
|
||
require.Equal(t, tt.want.SDFFilter, filter) | ||
require.Equal(t, tt.want.gateStatus, gateStatus) | ||
}, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters