Skip to content
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

Delete GUN functionality, requires * #819

Merged
merged 4 commits into from
Jul 15, 2016
Merged

Delete GUN functionality, requires * #819

merged 4 commits into from
Jul 15, 2016

Conversation

riyazdf
Copy link
Contributor

@riyazdf riyazdf commented Jul 8, 2016

Hooks up the handler for deleting a gun to the remote store and client library. Also changes the handler to require the admin * permission in the auth token.

I did some reworking of the transport code to make getting an admin permission more explicit, which should help with making creating a notary repo require the * permission as well. This PR as-is just defines the getAdminTransport function to be used if one was ever to want to put together a valid request with the * permission, but does not use it directly -- I figured it would be nice to include this, but I'm happy to expand this PR to include CLI commands for deletion, or remove that function for the time being if we'd prefer.

Partially addresses #789 and provides groundwork for #710 in the CLI

@riyazdf riyazdf added this to the Notary 0.4 milestone Jul 8, 2016
require.NoError(t, repo.Publish())

// Create another repo to ensure it stays intact
livingGun := "stayingAlive"
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Yay, thanks for ensuring that everything in the server isn't blown away. Also awesome name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Image of turtle dancing to staying alive

require.NotNil(t, auth)
}

func TestAdminTokenAuth200Status(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Totally non-blocking: good to have these here, but I'm not sure our existing auth tests actually do anything either other than reflect the 401 unauthorized handler. We don't actually test which permissions are asked for - I'm wondering if it's worth writing a mock jwt authorizer, so we can ensure that notary is asking for the correct permissions. However, a lot of that stuff is tested in the distribution library we depend on too.

What do you think? I can file an issue if that plumbing would be a useful thing for us to test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, definitely - I was wondering how we could better test for this, and @endophage might have more context around the token auth code and tests in distribution. I think a tracking issue would be good 👍

@cyli
Copy link
Contributor

cyli commented Jul 8, 2016

LGTM pending CI! Thanks for adding this so quickly!


// getAdminTransport returns an admin http.RoundTripper to be used for all http requests,
// and can be used for deleting repos
func getAdminTransport(config *viper.Viper, gun string) (http.RoundTripper, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless I'm missing something this is a dupe of getTransport immediately above with the only difference being readOnly is implicitly false. Seems unnecessary, especially as it's untested.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, sorry, saw the last arg for tokenAuth inverted too. Maybe we just update getTransport to take another arg?

Copy link
Contributor

@endophage endophage Jul 13, 2016

Choose a reason for hiding this comment

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

On third thoughts, maybe define an enum and make readOnly of that type, then get rid of adminAccess in tokenAuth

type httpAccess int

const (
    readOnly httpAccess = iota
    readWrite
    adminReadOnly
    adminReadWrite
)

or something like that

Signed-off-by: Riyaz Faizullabhoy <[email protected]>
@endophage
Copy link
Contributor

Love how this came out with the enum!

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants