Skip to content

Commit

Permalink
fix logic in transport test server (#10)
Browse files Browse the repository at this point in the history
The challenge acceptance logic was inverted since the challenge would
always fail as the server and client were using different cnonce values.
Make sure they are using the same cnonce, and invert the authorized
check.
  • Loading branch information
efd6 committed Oct 23, 2023
1 parent b7518f9 commit 1fc1d2b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestTransport(t *testing.T) {
cred2, err := Digest(chal, Options{
Method: r.Method,
URI: r.URL.RequestURI(),
Cnonce: cred.Cnonce,
Count: cred.Nc,
Username: username,
Password: password,
Expand All @@ -43,7 +44,7 @@ func TestTransport(t *testing.T) {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
authorized = cred.Response != cred2.Response
authorized = cred.Response == cred2.Response
}
if !authorized {
w.Header().Add("WWW-Authenticate", chal.String())
Expand Down

0 comments on commit 1fc1d2b

Please sign in to comment.