Skip to content

Ntlm test#1836

Closed
technoweenie wants to merge 5 commits intomasterfrom
ntlm-test
Closed

Ntlm test#1836
technoweenie wants to merge 5 commits intomasterfrom
ntlm-test

Conversation

@technoweenie
Copy link
Contributor

This adds an integration test for NTLM authentication.

Copy link
Contributor

@ttaylorr ttaylorr left a comment

Choose a reason for hiding this comment

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

Few comments, otherwise looks good 👍

func writeLFSError(w http.ResponseWriter, code int, msg string) {
by, err := json.Marshal(&lfsError{Message: msg})
if err != nil {
w.Header().Set("Content-Type", "text/plain")
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use http.Error(), which I think would look very clean:

by, err := json.Marshal(&lfsError{Message: msg})
if err != nil {
        http.Error(w, errors.Wrap(err, "json encoding error").Error(), 500)
        return
}

// ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rad.

w.WriteHeader(401)

// ntlmNegotiateMessage from httputil pkg
case "NTLM TlRMTVNTUAABAAAAB7IIogwADAAzAAAACwALACgAAAAKAAAoAAAAD1dJTExISS1NQUlOTk9SVEhBTUVSSUNB":
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be extracted to a const with some godoc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could, but it's already in httputil (and will be moved to lfsapi. Could just export it there, and use here.

begin_test "batch transfer"
(
set -e
exit 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to delete this locally? 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't look like anything to me.

)
end_test

begin_test "batch transfers with ntlm server"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, this looks really clean 👍

}

auth := authHeader[5:] // strip "ntlm " prefix
val, err := base64.StdEncoding.DecodeString(auth)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be using base64.UrlEncoding here since this is from an HTTP request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this is going in an http header and not a url parameter.

Copy link
Contributor

@ttaylorr ttaylorr left a comment

Choose a reason for hiding this comment

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

Thanks for addressing. Looks great!

@technoweenie
Copy link
Contributor Author

Closing in favor of #1840

@technoweenie technoweenie deleted the ntlm-test branch January 6, 2017 22:20
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.

2 participants