-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change model IDs to UUIDs Remove `deleted_at` from instances model
- Loading branch information
1 parent
1031987
commit 47cc9ce
Showing
45 changed files
with
589 additions
and
491 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.env | ||
gorm.db | ||
vendor/ | ||
gotrue | ||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import ( | |
jwt "github.com/dgrijalva/jwt-go" | ||
"github.com/netlify/gotrue/conf" | ||
"github.com/netlify/gotrue/models" | ||
"github.com/netlify/gotrue/storage/test" | ||
uuid "github.com/satori/go.uuid" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
|
@@ -25,7 +25,7 @@ type AdminTestSuite struct { | |
Config *conf.Configuration | ||
|
||
token string | ||
instanceID string | ||
instanceID uuid.UUID | ||
} | ||
|
||
func TestAdmin(t *testing.T) { | ||
|
@@ -37,12 +37,14 @@ func TestAdmin(t *testing.T) { | |
Config: config, | ||
instanceID: instanceID, | ||
} | ||
defer api.db.Close() | ||
//defer api.db.DropDB() | ||
|
||
suite.Run(t, ts) | ||
} | ||
|
||
func (ts *AdminTestSuite) SetupTest() { | ||
test.CleanupTables() | ||
ts.API.db.TruncateAll() | ||
ts.token = ts.makeSuperAdmin("[email protected]") | ||
} | ||
|
||
|
@@ -70,7 +72,7 @@ func (ts *AdminTestSuite) makeSuperAdmin(email string) string { | |
} | ||
|
||
func (ts *AdminTestSuite) makeSystemUser() string { | ||
u := models.NewSystemUser("", ts.Config.JWT.Aud) | ||
u := models.NewSystemUser(uuid.Nil, ts.Config.JWT.Aud) | ||
|
||
token, err := generateAccessToken(u, time.Second*time.Duration(ts.Config.JWT.Exp), ts.Config.JWT.Secret) | ||
require.NoError(ts.T(), err, "Error generating access token") | ||
|
@@ -107,6 +109,7 @@ func (ts *AdminTestSuite) TestAdminUsers() { | |
assert.Equal(ts.T(), "</admin/users?page=1>; rel=\"last\"", w.HeaderMap.Get("Link")) | ||
assert.Equal(ts.T(), "1", w.HeaderMap.Get("X-Total-Count")) | ||
|
||
fmt.Println(w.Body) | ||
data := struct { | ||
Users []*models.User `json:"users"` | ||
Aud string `json:"aud"` | ||
|
@@ -153,6 +156,8 @@ func (ts *AdminTestSuite) TestAdminUsers_SortAsc() { | |
u, err := models.NewUser(ts.instanceID, "[email protected]", "test", ts.Config.JWT.Aud, nil) | ||
require.NoError(ts.T(), err, "Error making new user") | ||
|
||
// if the created_at times are the same, then the sort order is not guaranteed | ||
time.Sleep(1 * time.Second) | ||
require.NoError(ts.T(), ts.API.db.CreateUser(u), "Error creating user") | ||
|
||
// Setup request | ||
|
@@ -182,6 +187,8 @@ func (ts *AdminTestSuite) TestAdminUsers_SortAsc() { | |
func (ts *AdminTestSuite) TestAdminUsers_SortDesc() { | ||
u, err := models.NewUser(ts.instanceID, "[email protected]", "test", ts.Config.JWT.Aud, nil) | ||
require.NoError(ts.T(), err, "Error making new user") | ||
// if the created_at times are the same, then the sort order is not guaranteed | ||
time.Sleep(1 * time.Second) | ||
require.NoError(ts.T(), ts.API.db.CreateUser(u), "Error creating user") | ||
|
||
// Setup request | ||
|
@@ -279,7 +286,7 @@ func (ts *AdminTestSuite) TestAdminUserCreate() { | |
|
||
// TestAdminUserGet tests API /admin/user route (GET) | ||
func (ts *AdminTestSuite) TestAdminUserGet() { | ||
u, err := models.NewUser(ts.instanceID, "[email protected]", "test", ts.Config.JWT.Aud, nil) | ||
u, err := models.NewUser(ts.instanceID, "[email protected]", "test", ts.Config.JWT.Aud, map[string]interface{}{"full_name": "Test Get User"}) | ||
require.NoError(ts.T(), err, "Error making new user") | ||
require.NoError(ts.T(), ts.API.db.CreateUser(u), "Error creating user") | ||
|
||
|
@@ -298,6 +305,8 @@ func (ts *AdminTestSuite) TestAdminUserGet() { | |
assert.Equal(ts.T(), data["email"], "[email protected]") | ||
assert.NotNil(ts.T(), data["app_metadata"]) | ||
assert.NotNil(ts.T(), data["user_metadata"]) | ||
md := data["user_metadata"].(map[string]interface{}) | ||
assert.Equal(ts.T(), "Test Get User", md["full_name"]) | ||
} | ||
|
||
// TestAdminUserUpdate tests API /admin/user route (UPDATE) | ||
|
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
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
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
Oops, something went wrong.