Skip to content

Commit

Permalink
test case for session admin without account
Browse files Browse the repository at this point in the history
  • Loading branch information
david-littlefarmer committed Oct 23, 2024
1 parent fc5febd commit 753f269
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"errors"
"net/http"

"github.com/0xsequence/authcontrol/proto"
"github.com/go-chi/jwtauth/v5"
"github.com/lestrrat-go/jwx/v2/jwt"

"github.com/0xsequence/authcontrol/proto"
)

type Options struct {
Expand Down
9 changes: 6 additions & 3 deletions middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import (
"testing"
"time"

"github.com/0xsequence/authcontrol"
"github.com/0xsequence/authcontrol/proto"
"github.com/go-chi/chi/v5"
"github.com/go-chi/jwtauth/v5"
"github.com/stretchr/testify/assert"

"github.com/0xsequence/authcontrol"
"github.com/0xsequence/authcontrol/proto"
)

type mockStore map[string]bool
Expand Down Expand Up @@ -104,6 +103,7 @@ func TestSession(t *testing.T) {
{Session: proto.SessionType_User},
{Session: proto.SessionType_User, Admin: true},
{Session: proto.SessionType_Admin},
{Session: proto.SessionType_Admin, Admin: true},
{Session: proto.SessionType_Admin, AccessKey: AccessKey},
{Session: proto.SessionType_Service},
{Session: proto.SessionType_Service, AccessKey: AccessKey},
Expand All @@ -128,6 +128,9 @@ func TestSession(t *testing.T) {
claims = map[string]any{"account": address}
case proto.SessionType_Admin:
claims = map[string]any{"account": WalletAddress, "admin": true}
if tc.Admin {
claims = map[string]any{"admin": true}
}
case proto.SessionType_Service:
claims = map[string]any{"service": ServiceName}
}
Expand Down

0 comments on commit 753f269

Please sign in to comment.