-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* define admin scope * remove duplications in permission scopes * bump version to 1.4.0
- Loading branch information
Showing
4 changed files
with
31 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module AuthenticJwt | ||
VERSION = "1.3.0" | ||
VERSION = "1.4.0" | ||
end |
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 |
---|---|---|
|
@@ -61,6 +61,22 @@ | |
}) | ||
end | ||
|
||
let(:editor_payload) do | ||
AuthenticJwt::Payload.new({ | ||
sub: "5", | ||
name: "Frodo Baggins", | ||
email: "[email protected]", | ||
username: "frodo", | ||
roles: [:SUBSCRIBER], | ||
accounts: [ | ||
AuthenticJwt::Payload::Account.new({ | ||
aud: ENV["AUTHENTIC_AUTH_ACCOUNT_ID"], | ||
roles: [:EDITOR], | ||
}) | ||
] | ||
}) | ||
end | ||
|
||
it "returns forbidden if the payload doesn't have access to the account" do | ||
expect { authorizer.call(payload: no_accounts_payload, scope: "write") }.to raise_error(AuthenticJwt::Forbidden, "No access to account") | ||
end | ||
|
@@ -73,6 +89,10 @@ | |
expect { authorizer.call(payload: insufficient_payload, scope: "write") }.to raise_error(AuthenticJwt::Forbidden, "Account role is too low") | ||
end | ||
|
||
it "returns forbidden if the payload account doesn't have admin access" do | ||
expect { authorizer.call(payload: editor_payload, scope: "admin") }.to raise_error(AuthenticJwt::Forbidden, "Account role is too low") | ||
end | ||
|
||
it "returns true if the payload is ok" do | ||
expect(authorizer.call(payload: valid_payload, scope: "write")).to eq(true) | ||
end | ||
|