-
Notifications
You must be signed in to change notification settings - Fork 5
Modify abilities to prevent link sharing #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
loiswells97
merged 8 commits into
main
from
issues/89-Modify_abilities_to_prevent_link_sharing
Dec 5, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c818509
Create draft PR for #89
loiswells97 08a3888
Update ability to prevent link sharing unless starter or example project
loiswells97 e9f94fc
Merge branch 'main' into issues/89-Modify_abilities_to_prevent_link_s…
loiswells97 356c737
some fixes
loiswells97 201efff
adding project show tests for new abilities
loiswells97 7606480
removing files added by mistake
loiswells97 7c25431
Adding ability spec and fixing rubocop
loiswells97 d349a28
Merge branch 'main' into issues/89-Modify_abilities_to_prevent_link_s…
patch0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'cancan/matchers' | ||
require 'rails_helper' | ||
|
||
RSpec.describe Ability do | ||
subject { described_class.new(user) } | ||
|
||
let(:project) { build(:project) } | ||
let(:another_project) { build(:project) } | ||
let(:starter_project) { build(:project, user_id: nil) } | ||
|
||
context 'when no user' do | ||
let(:user) { nil } | ||
|
||
context 'with a starter project' do | ||
it { is_expected.not_to be_able_to(:index, starter_project) } | ||
it { is_expected.to be_able_to(:show, starter_project) } | ||
it { is_expected.not_to be_able_to(:create, starter_project) } | ||
it { is_expected.not_to be_able_to(:update, starter_project) } | ||
it { is_expected.not_to be_able_to(:destroy, starter_project) } | ||
end | ||
|
||
context 'with an owned project' do | ||
it { is_expected.not_to be_able_to(:index, project) } | ||
it { is_expected.not_to be_able_to(:show, project) } | ||
it { is_expected.not_to be_able_to(:create, project) } | ||
it { is_expected.not_to be_able_to(:update, project) } | ||
it { is_expected.not_to be_able_to(:destroy, project) } | ||
end | ||
end | ||
|
||
context 'when user present' do | ||
let(:user) { project.user_id } | ||
|
||
context 'with a starter project' do | ||
it { is_expected.not_to be_able_to(:index, starter_project) } | ||
it { is_expected.to be_able_to(:show, starter_project) } | ||
it { is_expected.not_to be_able_to(:create, starter_project) } | ||
it { is_expected.not_to be_able_to(:update, starter_project) } | ||
it { is_expected.not_to be_able_to(:destroy, starter_project) } | ||
end | ||
|
||
context 'with own project' do | ||
it { is_expected.to be_able_to(:index, project) } | ||
it { is_expected.to be_able_to(:show, project) } | ||
it { is_expected.to be_able_to(:create, project) } | ||
it { is_expected.to be_able_to(:update, project) } | ||
it { is_expected.to be_able_to(:destroy, project) } | ||
end | ||
|
||
context 'with another user\'s project' do | ||
it { is_expected.not_to be_able_to(:index, another_project) } | ||
it { is_expected.not_to be_able_to(:show, another_project) } | ||
it { is_expected.not_to be_able_to(:create, another_project) } | ||
it { is_expected.not_to be_able_to(:update, another_project) } | ||
it { is_expected.not_to be_able_to(:destroy, another_project) } | ||
end | ||
end | ||
end |
This file contains hidden or 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
Empty file.
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather this was
:not_found
(no immediate information leakage about whether a project exists)Timing attacks would still give it away though, as less work is (probably) being done if no project is found.
Happy for this to be pushed into a new issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, we now have separate design for these two cases, so maybe this is part of a wider discussion...