-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9452fc9
commit 5675912
Showing
6 changed files
with
503 additions
and
250 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package mysqldb | ||
|
||
/* | ||
Copyright (C) 2019 Ulbora Labs LLC. (www.ulboralabs.com) | ||
All rights reserved. | ||
Copyright (C) 2019 Ken Williamson | ||
All rights reserved. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
//GetAccessTokenKey GetAccessTokenKey | ||
func (d *MySQLOauthDB) GetAccessTokenKey() string { | ||
var rtn string | ||
if !d.testConnection() { | ||
d.DB.Connect() | ||
} | ||
var a []interface{} | ||
row := d.DB.Get(getAccessTokenKey, a...) | ||
rtn = row.Row[1] | ||
return rtn | ||
} | ||
|
||
//GetRefreshTokenKey GetRefreshTokenKey | ||
func (d *MySQLOauthDB) GetRefreshTokenKey() string { | ||
var rtn string | ||
if !d.testConnection() { | ||
d.DB.Connect() | ||
} | ||
var a []interface{} | ||
row := d.DB.Get(getRefreshTokenKey, a...) | ||
rtn = row.Row[1] | ||
return rtn | ||
} | ||
|
||
//GetSessionKey GetSessionKey | ||
func (d *MySQLOauthDB) GetSessionKey() string { | ||
var rtn string | ||
if !d.testConnection() { | ||
d.DB.Connect() | ||
} | ||
var a []interface{} | ||
row := d.DB.Get(getSessionKey, a...) | ||
rtn = row.Row[1] | ||
return rtn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// +build integration move to top | ||
|
||
package mysqldb | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
odb "github.com/Ulbora/GoAuth2/oauth2database" | ||
db "github.com/Ulbora/dbinterface" | ||
mdb "github.com/Ulbora/dbinterface_mysql" | ||
) | ||
|
||
var dbKeyi db.Database | ||
var odbKeyi odb.Oauth2DB | ||
var cidKeyi int64 | ||
var idKeyi int64 | ||
|
||
func TestMySQLOauthDBKeyi_ConnectAllowURI(t *testing.T) { | ||
var mydb mdb.MyDB | ||
mydb.Host = "localhost:3306" | ||
mydb.User = "admin" | ||
mydb.Password = "admin" | ||
mydb.Database = "ulbora_oauth2_server" | ||
dbKeyi = &mydb | ||
|
||
var moadb MySQLOauthDB | ||
moadb.DB = dbKeyi | ||
|
||
odbKeyi = &moadb | ||
|
||
dbKeyi.Connect() | ||
} | ||
|
||
func TestMySQLOauthDBKeyi_GetAccessTokenKey(t *testing.T) { | ||
key := odbKeyi.GetAccessTokenKey() | ||
fmt.Println("access token key: ", key) | ||
if key == "" { | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestMySQLOauthDBKeyi_GetRefreshTokenKey(t *testing.T) { | ||
key := odbKeyi.GetRefreshTokenKey() | ||
fmt.Println("refresh token key: ", key) | ||
if key == "" { | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestMySQLOauthDBKeyi_GetSessionKey(t *testing.T) { | ||
key := odbKeyi.GetSessionKey() | ||
fmt.Println("session key: ", key) | ||
if key == "" { | ||
t.Fail() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package mysqldb | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
odb "github.com/Ulbora/GoAuth2/oauth2database" | ||
db "github.com/Ulbora/dbinterface" | ||
mdb "github.com/Ulbora/dbinterface_mysql" | ||
) | ||
|
||
var dbKey db.Database | ||
var odbKey odb.Oauth2DB | ||
var cidKey int64 | ||
var idKey int64 | ||
|
||
func TestMySQLOauthDBKey_ConnectAllowURI(t *testing.T) { | ||
var mydb mdb.MyDBMock | ||
mydb.Host = "localhost:3306" | ||
mydb.User = "admin" | ||
mydb.Password = "admin" | ||
mydb.Database = "ulbora_oauth2_server" | ||
dbKey = &mydb | ||
|
||
var moadb MySQLOauthDB | ||
moadb.DB = dbKey | ||
|
||
odbKey = &moadb | ||
|
||
dbKey.Connect() | ||
} | ||
|
||
func TestMySQLOauthDBKey_GetAccessTokenKey(t *testing.T) { | ||
var mydb mdb.MyDBMock | ||
mydb.Host = "localhost:3306" | ||
mydb.User = "admin" | ||
mydb.Password = "admin" | ||
mydb.Database = "ulbora_oauth2_server" | ||
dbKey = &mydb | ||
|
||
var mTestRow db.DbRow | ||
mTestRow.Row = []string{} | ||
mydb.MockTestRow = &mTestRow | ||
|
||
var getRow db.DbRow | ||
getRow.Row = []string{"1", "somekey"} | ||
mydb.MockRow1 = &getRow | ||
|
||
var moadb MySQLOauthDB | ||
moadb.DB = dbKey | ||
|
||
odbKey = &moadb | ||
|
||
dbKey.Connect() | ||
|
||
key := odbKey.GetAccessTokenKey() | ||
fmt.Println("access token key: ", key) | ||
if key == "" { | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestMySQLOauthDBKey_GetRefreshTokenKey(t *testing.T) { | ||
var mydb mdb.MyDBMock | ||
mydb.Host = "localhost:3306" | ||
mydb.User = "admin" | ||
mydb.Password = "admin" | ||
mydb.Database = "ulbora_oauth2_server" | ||
dbKey = &mydb | ||
|
||
var mTestRow db.DbRow | ||
mTestRow.Row = []string{} | ||
mydb.MockTestRow = &mTestRow | ||
|
||
var getRow db.DbRow | ||
getRow.Row = []string{"1", "somekey"} | ||
mydb.MockRow1 = &getRow | ||
|
||
var moadb MySQLOauthDB | ||
moadb.DB = dbKey | ||
|
||
odbKey = &moadb | ||
|
||
dbKey.Connect() | ||
|
||
key := odbKey.GetRefreshTokenKey() | ||
fmt.Println("refresh token key: ", key) | ||
if key == "" { | ||
t.Fail() | ||
} | ||
} | ||
|
||
func TestMySQLOauthDBKey_GetSessionKey(t *testing.T) { | ||
var mydb mdb.MyDBMock | ||
mydb.Host = "localhost:3306" | ||
mydb.User = "admin" | ||
mydb.Password = "admin" | ||
mydb.Database = "ulbora_oauth2_server" | ||
dbKey = &mydb | ||
|
||
var mTestRow db.DbRow | ||
mTestRow.Row = []string{} | ||
mydb.MockTestRow = &mTestRow | ||
|
||
var getRow db.DbRow | ||
getRow.Row = []string{"1", "somekey"} | ||
mydb.MockRow1 = &getRow | ||
|
||
var moadb MySQLOauthDB | ||
moadb.DB = dbKey | ||
|
||
odbKey = &moadb | ||
|
||
dbKey.Connect() | ||
|
||
key := odbKey.GetSessionKey() | ||
fmt.Println("session key: ", key) | ||
if key == "" { | ||
t.Fail() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters