Skip to content

Commit

Permalink
Implemented goconvey for User Authentication Tests
Browse files Browse the repository at this point in the history
Reference #580
  • Loading branch information
gjrtimmer committed Jun 4, 2018
1 parent 90f966b commit 11627e4
Show file tree
Hide file tree
Showing 6 changed files with 1,066 additions and 158 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ before_install:
fi
- |
if [[ "${GOOS}" != "windows" ]]; then
go get github.com/smartystreets/goconvey
go get github.com/mattn/goveralls
go get golang.org/x/tools/cmd/cover
fi
Expand Down
10 changes: 5 additions & 5 deletions sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
//
// If the SQLITE_USER table is not present in the database file, then
// this interface is a harmless no-op returnning SQLITE_OK.
if err := conn.RegisterFunc("authenticate", conn.authenticate, false); err != nil {
if err := conn.RegisterFunc("authenticate", conn.authenticate, true); err != nil {
return nil, err
}
//
Expand All @@ -1319,7 +1319,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
// The AuthUserAdd only works for the "main" database, not
// for any ATTACH-ed databases. Any call to AuthUserAdd by a
// non-admin user results in an error.
if err := conn.RegisterFunc("auth_user_add", conn.authUserAdd, false); err != nil {
if err := conn.RegisterFunc("auth_user_add", conn.authUserAdd, true); err != nil {
return nil, err
}
//
Expand All @@ -1329,7 +1329,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
// login credentials. Only an admin user can change another users login
// credentials or admin privilege setting. No user may change their own
// admin privilege setting.
if err := conn.RegisterFunc("auth_user_change", conn.authUserChange, false); err != nil {
if err := conn.RegisterFunc("auth_user_change", conn.authUserChange, true); err != nil {
return nil, err
}
//
Expand All @@ -1339,13 +1339,13 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
// which guarantees that there is always an admin user and hence that
// the database cannot be converted into a no-authentication-required
// database.
if err := conn.RegisterFunc("auth_user_delete", conn.authUserDelete, false); err != nil {
if err := conn.RegisterFunc("auth_user_delete", conn.authUserDelete, true); err != nil {
return nil, err
}

// Register: auth_enabled
// auth_enabled can be used to check if user authentication is enabled
if err := conn.RegisterFunc("auth_enabled", conn.authEnabled, false); err != nil {
if err := conn.RegisterFunc("auth_enabled", conn.authEnabled, true); err != nil {
return nil, err
}

Expand Down
11 changes: 11 additions & 0 deletions sqlite3.goconvey
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// GoConvey Test Profile

// Activate Coverage
-cover

-run=TestUserAuthentication

// Test Flags
-tags=sqlite_userauth

// EOF
Loading

0 comments on commit 11627e4

Please sign in to comment.