-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathscope_integration_test.go
91 lines (77 loc) · 1.7 KB
/
scope_integration_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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// +build integration move to top
package mysqldb
import (
"fmt"
"testing"
odb "github.com/Ulbora/GoAuth2/oauth2database"
lg "github.com/Ulbora/Level_Logger"
db "github.com/Ulbora/dbinterface"
mdb "github.com/Ulbora/dbinterface_mysql"
)
var dbSoi db.Database
var odbSoi odb.Oauth2DB
var cidSoi int64
var idSoi int64
func TestMySQLOauthDBi_ConnectScope(t *testing.T) {
var mydb mdb.MyDB
mydb.Host = "localhost:3306"
mydb.User = "admin"
mydb.Password = "admin"
mydb.Database = "ulbora_oauth2_server"
dbSoi = &mydb
var moadb MySQLOauthDB
var l lg.Logger
moadb.Log = &l
moadb.DB = dbSoi
odbSoi = &moadb
dbSoi.Connect()
}
func TestMySQLOauthDBi_AddClientInScope(t *testing.T) {
var c odb.Client
c.Secret = "12345"
c.Name = "tester"
c.Email = "[email protected]"
c.WebSite = "www.bob.com"
c.Enabled = true
c.Paid = false
fmt.Println("before db add")
res, id := odbSoi.AddClient(&c, nil)
fmt.Println("res: ", res)
fmt.Println("id: ", id)
if !res || id == 0 {
t.Fail()
} else {
cidSoi = id
}
}
func TestMySQLOauthDBi_AddClientScope(t *testing.T) {
var ur odb.ClientScope
ur.ClientID = cidSoi
ur.Scope = "somescope"
res, id := odbSoi.AddClientScope(&ur)
if !res || id <= 0 {
t.Fail()
} else {
idSoi = id
}
}
func TestMySQLOauthDBi_GetClientScopeList(t *testing.T) {
res := odbSoi.GetClientScopeList(cidSoi)
fmt.Println("scope list res: ", res)
if res == nil || (*res)[0].ClientID != cidSoi {
t.Fail()
}
}
func TestMySQLOauthDBi_DeleteClientScope(t *testing.T) {
res := odbSoi.DeleteClientScope(idSoi)
fmt.Println("scope delete: ", res)
if !res {
t.Fail()
}
}
func TestMySQLOauthDBi_DeleteClientInScope(t *testing.T) {
suc := odbSoi.DeleteClient(cidSoi)
if !suc {
t.Fail()
}
}