-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix auth service monitor wrapper to maintain EmailInviter implementat…
…ion when required (#7916)
- Loading branch information
Showing
6 changed files
with
93 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cmd_test | ||
|
||
import ( | ||
"context" | ||
"github.com/treeverse/lakefs/cmd/lakefs/cmd" | ||
"github.com/treeverse/lakefs/pkg/auth" | ||
"github.com/treeverse/lakefs/pkg/config" | ||
"github.com/treeverse/lakefs/pkg/logging" | ||
"testing" | ||
) | ||
|
||
func TestGetAuthService(t *testing.T) { | ||
t.Run("maintain_inviter", func(t *testing.T) { | ||
cfg := &config.Config{} | ||
cfg.Auth.API.Endpoint = "http://localhost:8000" | ||
cfg.Auth.API.SkipHealthCheck = true | ||
service := cmd.NewAuthService(context.Background(), cfg, logging.ContextUnavailable(), nil) | ||
_, ok := service.(auth.EmailInviter) | ||
if !ok { | ||
t.Fatalf("expected Service to be of type EmailInviter") | ||
} | ||
}) | ||
t.Run("maintain_service", func(t *testing.T) { | ||
cfg := &config.Config{} | ||
cfg.Auth.UIConfig.RBAC = config.AuthRBACSimplified | ||
service := cmd.NewAuthService(context.Background(), cfg, logging.ContextUnavailable(), nil) | ||
_, ok := service.(auth.EmailInviter) | ||
if ok { | ||
t.Fatalf("expected Service to not be of type EmailInviter") | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
package auth | ||
|
||
//go:generate go run github.com/treeverse/lakefs/tools/wrapgen --package auth --output ./wrapper.gen.go --interface Service ./service.go | ||
//go:generate go run github.com/treeverse/lakefs/tools/wrapgen --package auth --output ./service_inviter_wrapper.gen.go --interface ServiceAndInviter ./service.go | ||
//go:generate go run github.com/treeverse/lakefs/tools/wrapgen --package auth --output ./service_wrapper.gen.go --interface Service ./service.go | ||
|
||
// Must run goimports after wrapgen: it adds unused imports. | ||
//go:generate go run golang.org/x/tools/cmd/goimports@latest -w ./wrapper.gen.go | ||
//go:generate go run golang.org/x/tools/cmd/goimports@latest -w ./service_inviter_wrapper.gen.go | ||
//go:generate go run golang.org/x/tools/cmd/goimports@latest -w ./service_wrapper.gen.go | ||
|
||
//go:generate go run github.com/deepmap/oapi-codegen/cmd/[email protected] -package auth -generate "types,client" -o client.gen.go ../../api/authorization.yml | ||
//go:generate go run github.com/golang/mock/[email protected] -package=mock -destination=mock/mock_auth_client.go github.com/treeverse/lakefs/pkg/auth ClientWithResponsesInterface | ||
|
@@ -93,6 +95,11 @@ type ExternalPrincipalsService interface { | |
ListUserExternalPrincipals(ctx context.Context, userID string, params *model.PaginationParams) ([]*model.ExternalPrincipal, *model.Paginator, error) | ||
} | ||
|
||
type ServiceAndInviter interface { | ||
Service | ||
EmailInviter | ||
} | ||
|
||
type Service interface { | ||
SecretStore() crypt.SecretStore | ||
Cache() Cache | ||
|