-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathredirectUri_test.go
140 lines (117 loc) · 2.77 KB
/
redirectUri_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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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 dbbUri2 db.Database
var odbbUri2 odb.Oauth2DB
var rdid2 int64
var cidUri2 int64
func TestMySQLOauthDB2_Connect(t *testing.T) {
//var db db.Database
var mydb mdb.MyDBMock
mydb.Host = "localhost:3306"
mydb.User = "admin"
mydb.Password = "admin"
mydb.Database = "ulbora_oauth2_server"
dbbUri2 = &mydb
//mydb.MockTestRow
var mTestRow db.DbRow
mTestRow.Row = []string{}
mydb.MockTestRow = &mTestRow
mydb.MockInsertSuccess1 = true
mydb.MockInsertID1 = 1
var getRow db.DbRow
getRow.Row = []string{"1", "test", "2"}
mydb.MockRow1 = &getRow
var rows [][]string
row1 := []string{"1", "tester5", "2"}
rows = append(rows, row1)
var dbrows db.DbRows
dbrows.Rows = rows
mydb.MockRows1 = &dbrows
mydb.MockDeleteSuccess1 = true
mydb.MockDeleteSuccess2 = true
var moadb MySQLOauthDB
var l lg.Logger
moadb.Log = &l
moadb.DB = dbbUri2
odbbUri2 = &moadb
dbbUri2.Connect()
}
func TestMySQLOauthDB2_AddClientRedirectURI(t *testing.T) {
var ur odb.ClientRedirectURI
ur.ClientID = 4
ur.URI = "someuri"
res, id := odbbUri2.AddClientRedirectURI(nil, &ur)
if !res || id <= 0 {
t.Fail()
}
}
func TestMySQLOauthDB2_AddClientRedirectURITx(t *testing.T) {
var ur odb.ClientRedirectURI
ur.ClientID = 4
ur.URI = "someuri"
var mtx mdb.MyDbTxMock
var mdbx mdb.MyDBMock
mdbx.MockInsertSuccess1 = true
mdbx.MockInsertID1 = 1
mtx.MyDBMock = &mdbx
var moadbtx MySQLOauthDB
var l lg.Logger
moadbtx.Log = &l
//moadbtx.Tx = &mtx
var odbbUri2TX = &moadbtx
res, id := odbbUri2TX.AddClientRedirectURI(&mtx, &ur)
if !res || id <= 0 {
t.Fail()
}
}
func TestMySQLOauthDB2_GetClientRedirectURI(t *testing.T) {
var cid int64 = 2
res := odbbUri2.GetClientRedirectURI(cid, "someuri")
if res == nil {
t.Fail()
}
}
func TestMySQLOauthDB2_GetClientRedirectURIList(t *testing.T) {
var cid int64 = 2
res := odbbUri2.GetClientRedirectURIList(cid)
if res == nil || len(*res) == 0 {
t.Fail()
}
}
func TestMySQLOauthDB2_DeleteClientRedirectURI(t *testing.T) {
var id int64 = 2
res := odbbUri2.DeleteClientRedirectURI(nil, id)
if !res {
t.Fail()
}
}
func TestMySQLOauthDB2_DeleteClientRedirectURIAll(t *testing.T) {
var id int64 = 2
res := odbbUri2.DeleteClientAllRedirectURI(nil, id)
if !res {
t.Fail()
}
}
func TestMySQLOauthDB2_DeleteClientRedirectURITx(t *testing.T) {
var id int64 = 2
var mtx mdb.MyDbTxMock
var mdbx mdb.MyDBMock
mdbx.MockDeleteSuccess1 = true
mtx.MyDBMock = &mdbx
var moadbtx MySQLOauthDB
var l lg.Logger
moadbtx.Log = &l
//moadbtx.Tx = &mtx
var odbbUri2TX = &moadbtx
res := odbbUri2TX.DeleteClientRedirectURI(&mtx, id)
if !res {
t.Fail()
}
}