generated from VLADIMIR/template
fix
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"evening_detective_server/internal/modules/processor_jwt"
|
||||
"evening_detective_server/internal/services/ui_service"
|
||||
proto "evening_detective_server/proto"
|
||||
)
|
||||
|
||||
func TestGetPermissionsAllowsAnonymousUsers(t *testing.T) {
|
||||
s := &server{uiService: ui_service.NewUIService()}
|
||||
|
||||
rsp, err := s.GetPermissions(context.Background(), &proto.GetPermissionsReq{})
|
||||
if err != nil {
|
||||
t.Fatalf("GetPermissions() error = %v", err)
|
||||
}
|
||||
if len(rsp.GetPermissions()) != 0 {
|
||||
t.Fatalf("anonymous permissions = %v, want empty", rsp.GetPermissions())
|
||||
}
|
||||
|
||||
ctx := processor_jwt.ContextWithClaims(context.Background(), &processor_jwt.JWTClaims{Roles: []string{"user"}})
|
||||
rsp, err = s.GetPermissions(ctx, &proto.GetPermissionsReq{})
|
||||
if err != nil {
|
||||
t.Fatalf("GetPermissions() with claims error = %v", err)
|
||||
}
|
||||
if len(rsp.GetPermissions()) == 0 {
|
||||
t.Fatal("authenticated permissions are empty")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user