Skip to content

Commit

Permalink
fix: ensure tii signing secret is sent as a base64 string
Browse files Browse the repository at this point in the history
  • Loading branch information
macite committed Jul 25, 2024
1 parent 7e9adaa commit efa6692
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/models/turn_it_in/tii_action_register_webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def need_to_register_webhook?

def register_webhook
data = TCAClient::WebhookWithSecret.new(
signing_secret: ENV.fetch('TCA_SIGNING_KEY', nil),
signing_secret: Base64.encode64(ENV.fetch('TCA_SIGNING_KEY', nil)),
url: TurnItIn.webhook_url,
event_types: %w[
SIMILARITY_COMPLETE
Expand Down
32 changes: 16 additions & 16 deletions test/sidekiq/tii_webhooks_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ def test_register_webhooks
headers: {})

# and will register the webhooks
register_webhooks_stub = stub_request(:post, "https://#{ENV['TCA_HOST']}/api/v1/webhooks").
with(tii_headers).
with(
body: TCAClient::WebhookWithSecret.new(
signing_secret: ENV.fetch('TCA_SIGNING_KEY', nil),
url: TurnItIn.webhook_url,
event_types: [
'SIMILARITY_COMPLETE',
'SUBMISSION_COMPLETE',
'SIMILARITY_UPDATED',
'PDF_STATUS',
'GROUP_ATTACHMENT_COMPLETE'
]
).to_json,
).
to_return(status: 200, body: "", headers: {})
register_webhooks_stub = stub_request(:post, "https://#{ENV['TCA_HOST']}/api/v1/webhooks")
.with(tii_headers)
.with(
body: TCAClient::WebhookWithSecret.new(
signing_secret: Base64.encode64(ENV.fetch('TCA_SIGNING_KEY', nil)),
url: TurnItIn.webhook_url,
event_types: [
'SIMILARITY_COMPLETE',
'SUBMISSION_COMPLETE',
'SIMILARITY_UPDATED',
'PDF_STATUS',
'GROUP_ATTACHMENT_COMPLETE'
]
).to_json
)
.to_return(status: 200, body: "", headers: {})

job = TiiRegisterWebHookJob.new
job.perform
Expand Down

0 comments on commit efa6692

Please sign in to comment.