-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcredentialsGrant_integration_test.go
87 lines (72 loc) · 1.59 KB
/
credentialsGrant_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
// +build integration move to top
package mysqldb
import (
"fmt"
"testing"
"time"
odb "github.com/Ulbora/GoAuth2/oauth2database"
lg "github.com/Ulbora/Level_Logger"
db "github.com/Ulbora/dbinterface"
mdb "github.com/Ulbora/dbinterface_mysql"
)
var dbCgi db.Database
var odbCgi odb.Oauth2DB
var cidCgi int64
var spIDCgi int64
var spID2Cgi int64
func TestMySQLOauthDBCgi_Connect(t *testing.T) {
//var db db.Database
var mydb mdb.MyDB
mydb.Host = "localhost:3306"
mydb.User = "admin"
mydb.Password = "admin"
mydb.Database = "ulbora_oauth2_server"
dbCgi = &mydb
var moadb MySQLOauthDB
var l lg.Logger
moadb.Log = &l
moadb.DB = dbCgi
odbCgi = &moadb
dbCgi.Connect()
}
func TestMySQLOauthDBCgi_AddClientNullUri(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 := odbCgi.AddClient(&c, nil)
fmt.Println("client add res: ", res)
fmt.Println("client id: ", id)
if !res || id == 0 {
t.Fail()
} else {
cidCgi = id
}
}
func TestMySQLOauthDBCgi_AddCredentialsGrant(t *testing.T) {
var at odb.AccessToken
at.Token = "someacctoken"
at.Expires = time.Now()
var pwg odb.CredentialsGrant
pwg.ClientID = cidCgi
res, id := odbCgi.AddCredentialsGrant(&pwg, &at)
if !res || id < 1 {
t.Fail()
}
}
func TestMySQLOauthDBCgi_DeleteCredentialsGrant(t *testing.T) {
res := odbCgi.DeleteCredentialsGrant(cidCgi)
if !res {
t.Fail()
}
}
func TestMySQLOauthDBCgi_DeleteClient(t *testing.T) {
suc := odbCgi.DeleteClient(cidCgi)
if !suc {
t.Fail()
}
}