Skip to content

Commit

Permalink
fix: correct tests
Browse files Browse the repository at this point in the history
  • Loading branch information
1995parham committed Nov 24, 2024
1 parent f6be236 commit 934b206
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions internal/authenticator/auto_authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type AutoAuthenticator struct {
Validator validator.Client
Parser *jwt.Parser
Tracer trace.Tracer
metrics *metric.AutoAuthenticatorMetrics
Metrics *metric.AutoAuthenticatorMetrics
}

// Auth check user authentication by checking the user's token
Expand All @@ -50,12 +50,12 @@ func (a AutoAuthenticator) Auth(ctx context.Context, tokenString string) error {
start := time.Now()

if _, err := a.Validator.Validate(ctx, headers, "bearer "+tokenString); err != nil {
a.metrics.Latency(time.Since(start).Seconds(), a.Company, err)
a.Metrics.Latency(time.Since(start).Seconds(), a.Company, err)

return fmt.Errorf("token is invalid: %w", err)
}

a.metrics.Latency(time.Since(start).Seconds(), a.Company, nil)
a.Metrics.Latency(time.Since(start).Seconds(), a.Company, nil)

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions internal/authenticator/auto_authenticator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/golang-jwt/jwt/v5"
"github.com/snapp-incubator/soteria/internal/authenticator"
"github.com/snapp-incubator/soteria/internal/config"
"github.com/snapp-incubator/soteria/internal/metric"
"github.com/snapp-incubator/soteria/internal/topics"
"github.com/snapp-incubator/soteria/pkg/acl"
"github.com/snapp-incubator/soteria/pkg/validator"
Expand Down Expand Up @@ -95,6 +96,7 @@ func (suite *AutoAuthenticatorTestSuite) SetupSuite() {
Tracer: noop.NewTracerProvider().Tracer(""),
Company: "snapp",
Parser: jwt.NewParser(),
Metrics: metric.NewAutoAuthenticatorMetrics(),
TopicManager: topics.NewTopicManager(cfg.Topics, hid, "snapp", cfg.IssEntityMap, cfg.IssPeerMap, zap.NewNop()),
JWTConfig: config.JWT{
IssName: "iss",
Expand Down
2 changes: 1 addition & 1 deletion internal/authenticator/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (b Builder) autoAuthenticator(vendor config.Vendor) (*AutoAuthenticator, er
return &AutoAuthenticator{
AllowedAccessTypes: allowedAccessTypes,
Company: vendor.Company,
metrics: metric.NewAutoAuthenticatorMetrics(),
Metrics: metric.NewAutoAuthenticatorMetrics(),
TopicManager: topics.NewTopicManager(
vendor.Topics,
hid,
Expand Down

0 comments on commit 934b206

Please sign in to comment.