Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
clD11 committed Aug 10, 2024
1 parent 4de7c9b commit 993396b
Show file tree
Hide file tree
Showing 2 changed files with 381 additions and 7 deletions.
14 changes: 7 additions & 7 deletions services/skus/radom/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ func ParseEvent(b []byte) (Event, error) {
}

type MessageAuthConfig struct {
token string
disabled bool
token string
enabled bool
}

type MessageAuthenticator struct {
Expand All @@ -155,13 +155,13 @@ func NewMessageAuthenticator(cfg MessageAuthConfig) *MessageAuthenticator {
}

const (
ErrDisabled = model.Error("radom: radom disabled")
ErrVerificationKeyEmpty = model.Error("radom: verification key is empty")
ErrWebhookInvalidKey = model.Error("radom: verification key is invalid")
ErrDisabled = model.Error("radom: radom disabled")
ErrVerificationKeyEmpty = model.Error("radom: verification key is empty")
ErrVerificationKeyInvalid = model.Error("radom: verification key is invalid")
)

func (r *MessageAuthenticator) Authenticate(_ context.Context, token string) error {
if r.cfg.disabled {
if !r.cfg.enabled {
return ErrDisabled
}

Expand All @@ -170,7 +170,7 @@ func (r *MessageAuthenticator) Authenticate(_ context.Context, token string) err
}

if token != r.cfg.token {
return ErrWebhookInvalidKey
return ErrVerificationKeyInvalid
}

return nil
Expand Down
Loading

0 comments on commit 993396b

Please sign in to comment.