File size: 1,628 Bytes
530729e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
package common

import (
	"fmt"
	"regexp"

	"github.com/GoAdminGroup/go-admin/plugins/admin/modules/form"
	"github.com/gavv/httpexpect"
	"github.com/mgutz/ansi"
)

var reg, _ = regexp.Compile("<input type=\"hidden\" name=\"" + form.TokenKey + "\" value='(.*?)'>")

// ExtraTest contains unit test sections of the GoAdmin admin plugin.
func ExtraTest(e *httpexpect.Expect) {

	fmt.Println()
	fmt.Println("============================================")
	printlnWithColor("Basic Function Black-Box Testing", "blue")
	fmt.Println("============================================")
	fmt.Println()

	cookie := authTest(e)

	// permission check
	permissionTest(e, cookie)
	// role check
	roleTest(e, cookie)
	// manager check
	managerTest(e, cookie)
	// api check
	apiTest(e, cookie)
	// menu check
	menuTest(e, cookie)
	// operation log check
	operationLogTest(e, cookie)

	// get data from outside source check
	externalTest(e, cookie)
	// normal table tests
	normalTest(e, cookie)
}

// ExtraTest contains unit test sections of the GoAdmin admin plugin.
func Test(e *httpexpect.Expect) {

	fmt.Println()
	fmt.Println("============================================")
	printlnWithColor("Basic Function Black-Box Testing", "blue")
	fmt.Println("============================================")
	fmt.Println()

	cookie := authTest(e)

	// permission check
	permissionTest(e, cookie)
	// role check
	roleTest(e, cookie)
	// manager check
	managerTest(e, cookie)
	// menu check
	menuTest(e, cookie)
	// operation log check
	operationLogTest(e, cookie)
}

func printlnWithColor(msg string, color string) {
	fmt.Println(ansi.Color(msg, color))
}