diff --git a/endpoints/signup.go b/endpoints/signup.go index f9ba247..e083699 100644 --- a/endpoints/signup.go +++ b/endpoints/signup.go @@ -48,7 +48,7 @@ func (c *Client) Signup(req types.SignupRequest) (*types.SignupResponse, error) } // To make the response easier to consume, if autoconfirm was enabled, the - // session user should be popuated. Copy that into the embedded user type + // session user should be populated. Copy that into the embedded user type // so it's easier to access. // // i.e. we can access user fields like res.Email regardless of whether diff --git a/integration_test/adminaudit_test.go b/integration_test/adminaudit_test.go index 8bd4aff..b43f22e 100644 --- a/integration_test/adminaudit_test.go +++ b/integration_test/adminaudit_test.go @@ -9,10 +9,12 @@ import ( "github.com/supabase-community/gotrue-go/types" ) -// This test relies on running with an empty audit log. -// This appears to be fine with the default test settings, but if it becomes an -// issue locally or in CI, we can add a cleanup step to all tests, or rewrite -// to stop looking at specific numbers of log entries. +// This test creates some audit logs, then retrieves them with pagination. +// However, other tests running in parallel may also create logs, so we only +// check that _at least_ the logs we create here are returned. +// +// In order to test this functionality exactly, we need to run this test against +// a fresh database with an empty audit log table. func TestAdminAudit(t *testing.T) { assert := assert.New(t) require := require.New(t) @@ -45,9 +47,9 @@ func TestAdminAudit(t *testing.T) { }) require.NoError(err) assert.Len(resp.Logs, 4) - assert.EqualValues(10, resp.TotalCount) + assert.GreaterOrEqual(resp.TotalCount, 10) assert.EqualValues(2, resp.NextPage) - assert.EqualValues(3, resp.TotalPages) + assert.GreaterOrEqual(resp.TotalPages, uint(3)) resp, err = client.AdminAudit(types.AdminAuditRequest{ Page: 2, @@ -55,19 +57,18 @@ func TestAdminAudit(t *testing.T) { }) require.NoError(err) assert.Len(resp.Logs, 4) - assert.EqualValues(10, resp.TotalCount) + assert.GreaterOrEqual(resp.TotalCount, 10) assert.EqualValues(3, resp.NextPage) - assert.EqualValues(3, resp.TotalPages) + assert.GreaterOrEqual(resp.TotalPages, uint(3)) resp, err = client.AdminAudit(types.AdminAuditRequest{ Page: 3, PerPage: 4, }) require.NoError(err) - assert.Len(resp.Logs, 2) - assert.EqualValues(10, resp.TotalCount) - assert.EqualValues(0, resp.NextPage) - assert.EqualValues(3, resp.TotalPages) + assert.GreaterOrEqual(len(resp.Logs), 2) + assert.GreaterOrEqual(resp.TotalCount, 10) + assert.GreaterOrEqual(resp.TotalPages, uint(3)) // Invalid - empty query _, err = client.AdminAudit(types.AdminAuditRequest{ @@ -100,7 +101,7 @@ func TestAdminAudit(t *testing.T) { }, }) require.NoError(err) - assert.Len(resp.Logs, 10) + assert.GreaterOrEqual(len(resp.Logs), 10) resp, err = client.AdminAudit(types.AdminAuditRequest{ Query: &types.AuditQuery{ diff --git a/integration_test/admingeneratelink_test.go b/integration_test/admingeneratelink_test.go index a2c19bf..d6edbdb 100644 --- a/integration_test/admingeneratelink_test.go +++ b/integration_test/admingeneratelink_test.go @@ -30,7 +30,7 @@ func TestAdminGenerateLink(t *testing.T) { require.NoError(err) assert.EqualValues(resp.VerificationType, "signup") - linkRegexp := regexp.MustCompile(`^http://localhost:9999/\?token=[a-zA-Z0-9_-]+&type=signup&redirect_to=http://localhost:3000$`) + linkRegexp := regexp.MustCompile(`^http://localhost:9999/verify\?token=[a-zA-Z0-9_-]+&type=signup&redirect_to=http://localhost:3000$`) assert.Regexp(linkRegexp, resp.ActionLink) assert.NotEmpty(resp.HashedToken) assert.NotEmpty(resp.EmailOTP) @@ -148,7 +148,7 @@ func TestAdminGenerateLink(t *testing.T) { require.NoError(err) assert.Equal("http://localhost:3000", resp.RedirectTo) assert.EqualValues(resp.VerificationType, "email_change_current") - linkRegexp = regexp.MustCompile(`^http://localhost:9999/\?token=[a-zA-Z0-9_-]+&type=email_change&redirect_to=http://localhost:3000$`) + linkRegexp = regexp.MustCompile(`^http://localhost:9999/verify\?token=[a-zA-Z0-9_-]+&type=email_change&redirect_to=http://localhost:3000$`) assert.Regexp(linkRegexp, resp.ActionLink) assert.NotEmpty(resp.HashedToken) assert.NotEmpty(resp.EmailOTP) diff --git a/integration_test/setup/docker-compose.yaml b/integration_test/setup/docker-compose.yaml index 1f696bb..88b37e7 100644 --- a/integration_test/setup/docker-compose.yaml +++ b/integration_test/setup/docker-compose.yaml @@ -5,10 +5,10 @@ services: container_name: gotrue depends_on: - postgres - image: supabase/gotrue:v2.86.0 + image: supabase/gotrue:v2.157.0 restart: on-failure ports: - - '9999:9999' + - "9999:9999" environment: GOTRUE_JWT_SECRET: "secret" GOTRUE_DB_DRIVER: "postgres" @@ -30,10 +30,10 @@ services: container_name: gotrue_autoconfirm depends_on: - postgres - image: supabase/gotrue:v2.86.0 + image: supabase/gotrue:v2.157.0 restart: on-failure ports: - - '9998:9998' + - "9998:9998" environment: GOTRUE_JWT_SECRET: "secret" GOTRUE_DB_DRIVER: "postgres" @@ -62,10 +62,10 @@ services: container_name: gotrue_signup_disabled depends_on: - postgres - image: supabase/gotrue:v2.86.0 + image: supabase/gotrue:v2.157.0 restart: on-failure ports: - - '9997:9997' + - "9997:9997" environment: GOTRUE_JWT_SECRET: "secret" GOTRUE_DB_DRIVER: "postgres" @@ -90,7 +90,7 @@ services: dockerfile: Dockerfile.postgres.dev container_name: gotrue_postgres ports: - - '5432:5432' + - "5432:5432" environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=root diff --git a/integration_test/verify_test.go b/integration_test/verify_test.go index 52de583..26c396b 100644 --- a/integration_test/verify_test.go +++ b/integration_test/verify_test.go @@ -28,8 +28,8 @@ func TestVerify(t *testing.T) { }) require.NoError(err) assert.NotEmpty(vResp.URL) - assert.Equal("401", vResp.ErrorCode) - assert.Equal("unauthorized_client", vResp.Error) + assert.Equal("403", vResp.ErrorCode) + assert.Equal("access_denied", vResp.Error) // Test Verify, invalid request _, err = client.Verify(types.VerifyRequest{})