Skip to content

Commit

Permalink
research the issues with tests
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Dmytrenko <rdmytrenko@gmail.com>
  • Loading branch information
erka committed Dec 13, 2024
1 parent 5332292 commit dab54d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 4 additions & 0 deletions build/testing/integration/authz/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ func (s clientCallSet) assert(t *testing.T, ctx context.Context, client sdk.SDK)
type clientCall func(*testing.T, context.Context, sdk.SDK) error

func GetNamespace(in *flipt.GetNamespaceRequest) clientCall {
if in.GetNamespaceKey() == "" {
in.Key = "default"
}
return func(t *testing.T, ctx context.Context, s sdk.SDK) error {
_, err := s.Flipt().GetNamespace(ctx, in)
return fmt.Errorf("GetNamespace: %w", err)
Expand Down Expand Up @@ -434,6 +437,7 @@ func CreateRollout(in *flipt.CreateRolloutRequest) clientCall {
return fmt.Errorf("CreateRollout: %w", err)
}
}

func UpdateRollout(in *flipt.UpdateRolloutRequest) clientCall {
return func(t *testing.T, ctx context.Context, s sdk.SDK) error {
_, err := s.Flipt().UpdateRollout(ctx, in)
Expand Down
13 changes: 5 additions & 8 deletions internal/server/authz/middleware/grpc/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ type InterceptorOptions struct {
skippedServers []any
}

var (
// methods which should always skip authorization
skippedMethods = map[string]any{
"/flipt.auth.AuthenticationService/GetAuthenticationSelf": struct{}{},
"/flipt.auth.AuthenticationService/ExpireAuthenticationSelf": struct{}{},
}
)
// methods which should always skip authorization
var skippedMethods = map[string]any{
"/flipt.auth.AuthenticationService/GetAuthenticationSelf": struct{}{},
"/flipt.auth.AuthenticationService/ExpireAuthenticationSelf": struct{}{},
}

func skipped(ctx context.Context, info *grpc.UnaryServerInfo, o InterceptorOptions) bool {
// if we skip authentication then we must skip authorization
Expand Down Expand Up @@ -95,7 +93,6 @@ func AuthorizationRequiredInterceptor(logger *zap.Logger, policyVerifier authz.V
"request": request,
"authentication": auth,
})

if err != nil {
logger.Error("unauthorized", zap.Error(err))
return ctx, errUnauthorized
Expand Down

0 comments on commit dab54d5

Please sign in to comment.