Merge pull request #509 from r0ro/missing-reg-link
Add missing link headers for registration resource update.
This commit is contained in:
commit
eb3ef4c98c
|
|
@ -911,6 +911,10 @@ func (wfe *WebFrontEndImpl) Registration(response http.ResponseWriter, request *
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
response.Header().Set("Content-Type", "application/json")
|
response.Header().Set("Content-Type", "application/json")
|
||||||
|
response.Header().Add("Link", link(wfe.NewAuthz, "next"))
|
||||||
|
if len(wfe.SubscriberAgreementURL) > 0 {
|
||||||
|
response.Header().Add("Link", link(wfe.SubscriberAgreementURL, "terms-of-service"))
|
||||||
|
}
|
||||||
response.WriteHeader(http.StatusAccepted)
|
response.WriteHeader(http.StatusAccepted)
|
||||||
response.Write(jsonReply)
|
response.Write(jsonReply)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -799,6 +799,10 @@ func TestNewRegistration(t *testing.T) {
|
||||||
test.AssertEquals(
|
test.AssertEquals(
|
||||||
t, responseWriter.Header().Get("Location"),
|
t, responseWriter.Header().Get("Location"),
|
||||||
"/acme/reg/0")
|
"/acme/reg/0")
|
||||||
|
links := responseWriter.Header()["Link"]
|
||||||
|
test.AssertEquals(t, contains(links, "</acme/new-authz>;rel=\"next\""), true)
|
||||||
|
test.AssertEquals(t, contains(links, "<"+agreementURL+">;rel=\"terms-of-service\""), true)
|
||||||
|
|
||||||
test.AssertEquals(
|
test.AssertEquals(
|
||||||
t, responseWriter.Header().Get("Link"),
|
t, responseWriter.Header().Get("Link"),
|
||||||
"</acme/new-authz>;rel=\"next\"")
|
"</acme/new-authz>;rel=\"next\"")
|
||||||
|
|
@ -1019,6 +1023,15 @@ func TestAuthorization(t *testing.T) {
|
||||||
test.AssertNotError(t, err, "Couldn't unmarshal returned authorization object")
|
test.AssertNotError(t, err, "Couldn't unmarshal returned authorization object")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func contains(s []string, e string) bool {
|
||||||
|
for _, a := range s {
|
||||||
|
if a == e {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func TestRegistration(t *testing.T) {
|
func TestRegistration(t *testing.T) {
|
||||||
wfe := setupWFE(t)
|
wfe := setupWFE(t)
|
||||||
mux, err := wfe.Handler()
|
mux, err := wfe.Handler()
|
||||||
|
|
@ -1121,6 +1134,10 @@ func TestRegistration(t *testing.T) {
|
||||||
URL: path,
|
URL: path,
|
||||||
})
|
})
|
||||||
test.AssertNotContains(t, responseWriter.Body.String(), "urn:acme:error")
|
test.AssertNotContains(t, responseWriter.Body.String(), "urn:acme:error")
|
||||||
|
links := responseWriter.Header()["Link"]
|
||||||
|
test.AssertEquals(t, contains(links, "</acme/new-authz>;rel=\"next\""), true)
|
||||||
|
test.AssertEquals(t, contains(links, "<"+agreementURL+">;rel=\"terms-of-service\""), true)
|
||||||
|
|
||||||
responseWriter.Body.Reset()
|
responseWriter.Body.Reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue