mirror of
https://github.com/iv-org/invidious.git
synced 2026-11-20 10:45:29 +00:00
* chore: Encapsulate more functions into their own modules and improve specs * update path for required .cr file in search/hastag_spec.cr * make the linter happy * Align PR changes with the current source code
27 lines
889 B
Crystal
27 lines
889 B
Crystal
require "../../spec_helper"
|
|
|
|
Spectator.describe Invidious::Helpers::Tokens do
|
|
describe ".sign_token" do
|
|
it "correctly signs a given hash" do
|
|
token = {
|
|
"session" => "v1:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
|
"expires" => 1554680038,
|
|
"scopes" => [
|
|
":notifications",
|
|
":subscriptions/*",
|
|
"GET:tokens*",
|
|
],
|
|
"signature" => "f__2hS20th8pALF305PJFK-D2aVtvefNnQheILHD2vU=",
|
|
}
|
|
expect(Invidious::Helpers::Tokens.sign_token("SECRET_KEY", token)).to eq(token["signature"])
|
|
|
|
token = {
|
|
"session" => "v1:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
|
"scopes" => [":notifications", "POST:subscriptions/*"],
|
|
"signature" => "fNvXoT0MRAL9eE6lTE33CEg8HitYJDOL9a22rSN2Ihg=",
|
|
}
|
|
expect(Invidious::Helpers::Tokens.sign_token("SECRET_KEY", token)).to eq(token["signature"])
|
|
end
|
|
end
|
|
end
|