-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgosddl_test.go
77 lines (69 loc) · 1.4 KB
/
gosddl_test.go
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package gosddl
import (
"testing"
"io/ioutil"
"os"
)
func TestProcessor(t *testing.T) {
var app ACLProcessor
testStr := "{O:WA,G:SA}"
err := app.Processor(testStr)
if err != nil {
t.Error(err)
return
}
}
func TestFindGroupIndex(t *testing.T) {
var app ACLProcessor
testStr := "{O:WA,G:SA}"
err := app.findGroupIndex(testStr)
if err != nil {
t.Error(err)
return
}
}
func TestFindGroupIndex2(t *testing.T) {
var app ACLProcessor
testStr := "{O:WA,G:SA,D:(SA;DA;;;;DA),S:AI(SA;DA;;;;ST)}"
err := app.findGroupIndex(testStr)
if err != nil {
t.Error(err)
return
}
}
func TestSidReplace(t *testing.T) {
data := []byte("S-10-10,User\n")
err := ioutil.WriteFile("test.txt", data, 0644)
if err != nil {
t.Error("can't write data test.txt", err)
return
}
str := checkSIDsFile("test.txt", "S-10-10")
err = os.Remove("test.txt")
if err != nil {
t.Error("can't delete file", err)
return
}
if str == "User" {
return
}
t.Errorf("replaced name doesn't match result: %s", str)
}
func TestReplacer(t *testing.T) {
var app ACLProcessor
testStr := "S-1-5-2"
str := app.sidReplace(testStr)
if str == "Network" {
return
}
t.Errorf("replaced name doesn't match result: %s", str)
}
func TestSplitBodyACL(t *testing.T) {
var app ACLProcessor
testStr := "SA;DA;;;;ST"
result := app.splitBodyACL(testStr)
if result.AccountSid == "" {
t.Error("function return nil data")
return
}
}