roles
This commit is contained in:
parent
8c8cbfd7dd
commit
41d48bf60a
28 changed files with 434 additions and 7 deletions
34
auth/authmiddleware/validation_test.go
Normal file
34
auth/authmiddleware/validation_test.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package authmiddleware_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.sapphic.engineer/roleypoly/v4/authmiddleware"
|
||||
"git.sapphic.engineer/roleypoly/v4/discord/clientmock"
|
||||
"git.sapphic.engineer/roleypoly/v4/types/fixtures"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestExpiration(t *testing.T) {
|
||||
dc := clientmock.NewDiscordClientMock()
|
||||
app := getApp(dc)
|
||||
|
||||
mockUser(dc, &fixtures.User)
|
||||
cookie, err := setSession(app, dc, authmiddleware.Session{
|
||||
AccessToken: "access-token",
|
||||
}, nil)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// Good request for now,,
|
||||
err = get(t, app, cookie, "/must/user")
|
||||
assert.Nil(t, err)
|
||||
|
||||
mockUser(dc, nil)
|
||||
cookie, err = setSession(app, dc, authmiddleware.Session{
|
||||
AccessToken: "access-token",
|
||||
}, cookie)
|
||||
assert.Nil(t, err)
|
||||
|
||||
err = get(t, app, cookie, "/must/user")
|
||||
assert.ErrorIs(t, errUnauthorized, err)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue