generated from VLADIMIR/template
fix
This commit is contained in:
@@ -168,6 +168,7 @@ func main() {
|
|||||||
grpc.UnaryInterceptor(
|
grpc.UnaryInterceptor(
|
||||||
processor_jwt.NewAuthorizationInterceptor(
|
processor_jwt.NewAuthorizationInterceptor(
|
||||||
map[string]bool{
|
map[string]bool{
|
||||||
|
"/crabs.evening_detective_server.EveningDetectiveServer/GetPermissions": true,
|
||||||
"/crabs.evening_detective_server.EveningDetectiveServer/GetParticipation": true,
|
"/crabs.evening_detective_server.EveningDetectiveServer/GetParticipation": true,
|
||||||
"/crabs.evening_detective_server.EveningDetectiveServer/GetTicket": true,
|
"/crabs.evening_detective_server.EveningDetectiveServer/GetTicket": true,
|
||||||
"/crabs.evening_detective_server.EveningDetectiveServer/AnswerParticipation": true,
|
"/crabs.evening_detective_server.EveningDetectiveServer/AnswerParticipation": true,
|
||||||
|
|||||||
@@ -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