Skip to content

Commit

Permalink
Updating test names
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosperes committed Apr 1, 2024
1 parent 127729e commit ab77e1c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions server/handlers/delete_account_oauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDeleteAccountOauth(t *testing.T) {
return http.ErrUseLastResponse
}

t.Run("delete social account", func(t *testing.T) {
t.Run("success", func(t *testing.T) {
account, err := app.AccountStore.Create("deleted-social-account@keratin.tech", []byte("password"))
require.NoError(t, err)

Expand All @@ -40,15 +40,15 @@ func TestDeleteAccountOauth(t *testing.T) {
require.Equal(t, []byte{}, test.ReadBody(res))
})

t.Run("return not found when user does not exists", func(t *testing.T) {
t.Run("user does not exist", func(t *testing.T) {
payload := map[string]interface{}{"oauth_providers": []string{"test"}}
res, err := client.DeleteJSON("/accounts/9999/oauth", payload)
require.NoError(t, err)

require.Equal(t, http.StatusNotFound, res.StatusCode)
})

t.Run("return unprocessable entity when user requires a new password", func(t *testing.T) {
t.Run("requires new password", func(t *testing.T) {
expected := "{\"errors\":[{\"field\":\"password\",\"message\":\"NEW_PASSWORD_REQUIRED\"}]}"
account, err := app.AccountStore.Create("deleted-unprocessable-entity@keratin.tech", []byte("password"))
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions server/handlers/delete_oauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ func TestDeleteOauthAccount(t *testing.T) {
return http.ErrUseLastResponse
}

t.Run("unanthorized", func(t *testing.T) {
t.Run("unauthorized", func(t *testing.T) {
res, err := client.Delete("/oauth/test")
require.NoError(t, err)

require.Equal(t, http.StatusUnauthorized, res.StatusCode)
require.Equal(t, []byte{}, test.ReadBody(res))
})

t.Run("delete social account", func(t *testing.T) {
t.Run("success", func(t *testing.T) {
account, err := app.AccountStore.Create("deleted@keratin.tech", []byte("password"))
require.NoError(t, err)

Expand All @@ -58,7 +58,7 @@ func TestDeleteOauthAccount(t *testing.T) {
require.Equal(t, []byte{}, test.ReadBody(res))
})

t.Run("return unprocessable entity when user requires a new password", func(t *testing.T) {
t.Run("requires new password", func(t *testing.T) {
expected := "{\"errors\":[{\"field\":\"password\",\"message\":\"NEW_PASSWORD_REQUIRED\"}]}"
account, err := app.AccountStore.Create("deleted-unprocessable-entity@keratin.tech", []byte("password"))
require.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion server/handlers/get_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"sort"
"testing"
"time"

"github.com/keratin/authn-server/app/models"
"github.com/keratin/authn-server/lib/route"
Expand Down Expand Up @@ -90,7 +91,7 @@ func assertGetAccountResponse(t *testing.T, res *http.Response, acc *models.Acco
},
},
LastLoginAt: "",
PasswordChangedAt: acc.PasswordChangedAt.Format("2006-01-02T15:04:05Z07:00"),
PasswordChangedAt: acc.PasswordChangedAt.Format(time.RFC3339),
Locked: false,
Deleted: false,
})
Expand Down
4 changes: 2 additions & 2 deletions server/handlers/get_oauth_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestGetOauthInfo(t *testing.T) {
Value: "",
})

t.Run("unanthorized", func(t *testing.T) {
t.Run("unauthorized", func(t *testing.T) {
res, err := client.Get("/oauth/info")
require.NoError(t, err)

require.Equal(t, http.StatusUnauthorized, res.StatusCode)
require.Equal(t, []byte{}, test.ReadBody(res))
})

t.Run("get oauth info", func(t *testing.T) {
t.Run("success", func(t *testing.T) {
expected := "{\"result\":[{\"email\":\"email\",\"provider\":\"test\",\"provider_account_id\":\"ID\"}]}"
account, err := app.AccountStore.Create("get-oauth-info@keratin.tech", []byte("password"))
require.NoError(t, err)
Expand Down

0 comments on commit ab77e1c

Please sign in to comment.