Skip to content

Issue #680 : Crate owners can now remove themselves as owner #999

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
merged 3 commits into from
Aug 27, 2017

Conversation

autodidaddict
Copy link
Contributor

If there is at least one other owner remaining, then an owner can remove themselves from a crate.

@autodidaddict
Copy link
Contributor Author

@carols10cents is there something you need from me to facilitate the review?

@carols10cents
Copy link
Member

Oh @vignesh-sankaran mentioned he wanted to try reviewing this one :)

// Ensures that so long as at least one owner remains associated with the crate,
// a user can still remove their own login as an owner
#[test]
fn owners_can_remove_self() {
Copy link
Contributor

@vignesh-sankaran vignesh-sankaran Aug 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding a test here, it's appreciated :). It helps in that it increases the test coverage of the backend.

@vignesh-sankaran
Copy link
Contributor

vignesh-sankaran commented Aug 27, 2017

Ok so from a functionality standpoint, this works fine, I tried adding another user, deleting the mock crate owner and then attempting to delete the sole crate owner, and it worked fine.

From a commit perspective, could you try squashing the commits down into 1 commit i.e. the first one? In your case, what you'd need to do is run git rebase -i 7bdb382, and squash the last 2 commits so that they get rolled up into the first commit of this PR. What this command does is that it rebases everything after the commit hash of the commit we want everything to appear squashed into. You'll need to git push -f to force the rebase upstream once you've completed the squash. Let us know if you get stuck with this.

Aside from that, I think we're good to merge this code in :).

@carols10cents
Copy link
Member

Hm there are still a lot of changes in the full diff, so the one squashed-down commit would still be pretty noisy. I think we can just take out the 2nd commit entirely and then squash the 3rd into the 1st.

I'm guessing the old version of rustfmt you had reordered the use statements, and then the newer version didn't reorder the use statements, so it left them reordered :)

I might just go ahead and take care of this actually...

@autodidaddict
Copy link
Contributor Author

autodidaddict commented Aug 27, 2017 via email

@carols10cents
Copy link
Member

Ah yeah then, no problem, i got it :)

… if there is at least one other owner remaining.

let mut response = ok_resp!(middle.call(req.with_method(Method::Get)));
let r: R = ::json(&mut response);
assert_eq!(r.users.len(), 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it looks like L1255-1257 are doing the exact same request and exact same assertion as L1251-1253, without any action in between? I'm going to remove the duplication while i'm in here, please let me know if there was a particular reason it was there that i'm missing :)

let mut response = ok_resp!(middle.call(req.with_method(Method::Delete).with_body(
body.as_bytes(),
)));
::json::<::Bad>(&mut response);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this test is checking that after you remove yourself as an owner, you should not be allowed to remove other people as owners (because you no longer have permission). I think we're missing coverage for the case where the only owner attempts to remove themselves-- I'm going to repeat the request from L1266-1269 before the second owner is added, and assert that it's not allowed.

@carols10cents
Copy link
Member

bors: r+

bors-voyager bot added a commit that referenced this pull request Aug 27, 2017
999: Issue #680 : Crate owners can now remove themselves as owner  r=carols10cents

If there is at least one other owner remaining, then an owner can remove themselves from a crate.
@bors-voyager
Copy link
Contributor

bors-voyager bot commented Aug 27, 2017

Build succeeded

@bors-voyager bors-voyager bot merged commit f25ec1c into rust-lang:master Aug 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants