forked from layeh/radius
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattribute_test.go
More file actions
59 lines (55 loc) · 1.15 KB
/
attribute_test.go
File metadata and controls
59 lines (55 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package radius
import (
"fmt"
"testing"
)
func TestMakeAttributeKey(t *testing.T) {
key := MakeAttributeKey(334324, 9, 16)
if key.Type() != 16 {
t.Fail()
}
if key.Vendor() != 334324 {
t.Fail()
}
if key.Tag() != 9 {
t.Fail()
}
if fmt.Sprint(key) != "(Vendor = 334324, Type = 16, Tag = 9)" {
t.Fatal(key)
}
if AttrUserName.String() != "User-Name" {
t.Fatal(AttrUserName)
}
if AttrTunnelPrivateGroupId.WithTag(1).String() != "Tunnel-Private-Group-Id:1" {
t.Fail()
}
}
func TestAttributeKey_WithTag(t *testing.T) {
key := MakeAttributeKey(334324, 9, 16)
newKey := key.WithTag(8)
if newKey.Tag() != 8 || newKey.Type() != 16 || newKey.Vendor() != 334324 {
t.Fail()
}
}
func TestAttributeKey_WithoutTag(t *testing.T) {
key := MakeAttributeKey(334324, 9, 16)
newKey := key.WithoutTag()
if newKey.Tag() != 0 || newKey.Type() != 16 || newKey.Vendor() != 334324 {
t.Fail()
}
}
func TestAttributeKey_ValidTag(t *testing.T) {
key := MakeAttributeKey(334324, 9, 16)
if !key.ValidTag() {
t.Fail()
}
if key.WithTag(0).ValidTag() {
t.Fail()
}
if !key.WithTag(0x1F).ValidTag() {
t.Fail()
}
if key.WithTag(0x20).ValidTag() {
t.Fail()
}
}