|
@@ -74,7 +74,7 @@ func TestDiscover(t *testing.T) {
|
|
|
revoke = "https://example.com/acme/revoke-cert"
|
|
revoke = "https://example.com/acme/revoke-cert"
|
|
|
)
|
|
)
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
- w.Header().Set("content-type", "application/json")
|
|
|
|
|
|
|
+ w.Header().Set("Content-Type", "application/json")
|
|
|
fmt.Fprintf(w, `{
|
|
fmt.Fprintf(w, `{
|
|
|
"new-reg": %q,
|
|
"new-reg": %q,
|
|
|
"new-authz": %q,
|
|
"new-authz": %q,
|
|
@@ -107,7 +107,7 @@ func TestRegister(t *testing.T) {
|
|
|
|
|
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
- w.Header().Set("replay-nonce", "test-nonce")
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", "test-nonce")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
if r.Method != "POST" {
|
|
if r.Method != "POST" {
|
|
@@ -173,7 +173,7 @@ func TestUpdateReg(t *testing.T) {
|
|
|
|
|
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
- w.Header().Set("replay-nonce", "test-nonce")
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", "test-nonce")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
if r.Method != "POST" {
|
|
if r.Method != "POST" {
|
|
@@ -234,7 +234,7 @@ func TestGetReg(t *testing.T) {
|
|
|
|
|
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
- w.Header().Set("replay-nonce", "test-nonce")
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", "test-nonce")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
if r.Method != "POST" {
|
|
if r.Method != "POST" {
|
|
@@ -290,7 +290,7 @@ func TestGetReg(t *testing.T) {
|
|
|
func TestAuthorize(t *testing.T) {
|
|
func TestAuthorize(t *testing.T) {
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
- w.Header().Set("replay-nonce", "test-nonce")
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", "test-nonce")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
if r.Method != "POST" {
|
|
if r.Method != "POST" {
|
|
@@ -394,7 +394,7 @@ func TestAuthorize(t *testing.T) {
|
|
|
func TestAuthorizeValid(t *testing.T) {
|
|
func TestAuthorizeValid(t *testing.T) {
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
- w.Header().Set("replay-nonce", "nonce")
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", "nonce")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
w.WriteHeader(http.StatusCreated)
|
|
w.WriteHeader(http.StatusCreated)
|
|
@@ -488,7 +488,7 @@ func TestWaitAuthorization(t *testing.T) {
|
|
|
var count int
|
|
var count int
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
count++
|
|
count++
|
|
|
- w.Header().Set("retry-after", "0")
|
|
|
|
|
|
|
+ w.Header().Set("Retry-After", "0")
|
|
|
if count > 1 {
|
|
if count > 1 {
|
|
|
fmt.Fprintf(w, `{"status":"valid"}`)
|
|
fmt.Fprintf(w, `{"status":"valid"}`)
|
|
|
return
|
|
return
|
|
@@ -551,7 +551,7 @@ func TestWaitAuthorizationInvalid(t *testing.T) {
|
|
|
|
|
|
|
|
func TestWaitAuthorizationCancel(t *testing.T) {
|
|
func TestWaitAuthorizationCancel(t *testing.T) {
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
- w.Header().Set("retry-after", "60")
|
|
|
|
|
|
|
+ w.Header().Set("Retry-After", "60")
|
|
|
fmt.Fprintf(w, `{"status":"pending"}`)
|
|
fmt.Fprintf(w, `{"status":"pending"}`)
|
|
|
}))
|
|
}))
|
|
|
defer ts.Close()
|
|
defer ts.Close()
|
|
@@ -579,7 +579,7 @@ func TestWaitAuthorizationCancel(t *testing.T) {
|
|
|
func TestRevokeAuthorization(t *testing.T) {
|
|
func TestRevokeAuthorization(t *testing.T) {
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
- w.Header().Set("replay-nonce", "nonce")
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", "nonce")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
switch r.URL.Path {
|
|
switch r.URL.Path {
|
|
@@ -652,7 +652,7 @@ func TestPollChallenge(t *testing.T) {
|
|
|
func TestAcceptChallenge(t *testing.T) {
|
|
func TestAcceptChallenge(t *testing.T) {
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
- w.Header().Set("replay-nonce", "test-nonce")
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", "test-nonce")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
if r.Method != "POST" {
|
|
if r.Method != "POST" {
|
|
@@ -718,7 +718,7 @@ func TestNewCert(t *testing.T) {
|
|
|
|
|
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
- w.Header().Set("replay-nonce", "test-nonce")
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", "test-nonce")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
if r.Method != "POST" {
|
|
if r.Method != "POST" {
|
|
@@ -801,7 +801,7 @@ func TestFetchCert(t *testing.T) {
|
|
|
count++
|
|
count++
|
|
|
if count < 3 {
|
|
if count < 3 {
|
|
|
up := fmt.Sprintf("<%s>;rel=up", ts.URL)
|
|
up := fmt.Sprintf("<%s>;rel=up", ts.URL)
|
|
|
- w.Header().Set("link", up)
|
|
|
|
|
|
|
+ w.Header().Set("Link", up)
|
|
|
}
|
|
}
|
|
|
w.Write([]byte{count})
|
|
w.Write([]byte{count})
|
|
|
}))
|
|
}))
|
|
@@ -820,7 +820,7 @@ func TestFetchCertRetry(t *testing.T) {
|
|
|
var count int
|
|
var count int
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if count < 1 {
|
|
if count < 1 {
|
|
|
- w.Header().Set("retry-after", "0")
|
|
|
|
|
|
|
+ w.Header().Set("Retry-After", "0")
|
|
|
w.WriteHeader(http.StatusAccepted)
|
|
w.WriteHeader(http.StatusAccepted)
|
|
|
count++
|
|
count++
|
|
|
return
|
|
return
|
|
@@ -840,7 +840,7 @@ func TestFetchCertRetry(t *testing.T) {
|
|
|
|
|
|
|
|
func TestFetchCertCancel(t *testing.T) {
|
|
func TestFetchCertCancel(t *testing.T) {
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
- w.Header().Set("retry-after", "0")
|
|
|
|
|
|
|
+ w.Header().Set("Retry-After", "0")
|
|
|
w.WriteHeader(http.StatusAccepted)
|
|
w.WriteHeader(http.StatusAccepted)
|
|
|
}))
|
|
}))
|
|
|
defer ts.Close()
|
|
defer ts.Close()
|
|
@@ -867,7 +867,7 @@ func TestFetchCertDepth(t *testing.T) {
|
|
|
t.Errorf("count = %d; want at most %d", count, maxChainLen+1)
|
|
t.Errorf("count = %d; want at most %d", count, maxChainLen+1)
|
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
|
}
|
|
}
|
|
|
- w.Header().Set("link", fmt.Sprintf("<%s>;rel=up", ts.URL))
|
|
|
|
|
|
|
+ w.Header().Set("Link", fmt.Sprintf("<%s>;rel=up", ts.URL))
|
|
|
w.Write([]byte{count})
|
|
w.Write([]byte{count})
|
|
|
}))
|
|
}))
|
|
|
defer ts.Close()
|
|
defer ts.Close()
|
|
@@ -881,7 +881,7 @@ func TestFetchCertBreadth(t *testing.T) {
|
|
|
var ts *httptest.Server
|
|
var ts *httptest.Server
|
|
|
ts = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
for i := 0; i < maxChainLen+1; i++ {
|
|
for i := 0; i < maxChainLen+1; i++ {
|
|
|
- w.Header().Add("link", fmt.Sprintf("<%s>;rel=up", ts.URL))
|
|
|
|
|
|
|
+ w.Header().Add("Link", fmt.Sprintf("<%s>;rel=up", ts.URL))
|
|
|
}
|
|
}
|
|
|
w.Write([]byte{1})
|
|
w.Write([]byte{1})
|
|
|
}))
|
|
}))
|
|
@@ -907,7 +907,7 @@ func TestFetchCertSize(t *testing.T) {
|
|
|
func TestRevokeCert(t *testing.T) {
|
|
func TestRevokeCert(t *testing.T) {
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
- w.Header().Set("replay-nonce", "nonce")
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", "nonce")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -977,7 +977,7 @@ func TestNonce_fetch(t *testing.T) {
|
|
|
if r.Method != "HEAD" {
|
|
if r.Method != "HEAD" {
|
|
|
t.Errorf("%d: r.Method = %q; want HEAD", i, r.Method)
|
|
t.Errorf("%d: r.Method = %q; want HEAD", i, r.Method)
|
|
|
}
|
|
}
|
|
|
- w.Header().Set("replay-nonce", tests[i].nonce)
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", tests[i].nonce)
|
|
|
w.WriteHeader(tests[i].code)
|
|
w.WriteHeader(tests[i].code)
|
|
|
}))
|
|
}))
|
|
|
defer ts.Close()
|
|
defer ts.Close()
|
|
@@ -1018,7 +1018,7 @@ func TestNonce_postJWS(t *testing.T) {
|
|
|
seen := make(map[string]bool)
|
|
seen := make(map[string]bool)
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
count++
|
|
count++
|
|
|
- w.Header().Set("replay-nonce", fmt.Sprintf("nonce%d", count))
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", fmt.Sprintf("nonce%d", count))
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
// We expect the client do a HEAD request
|
|
// We expect the client do a HEAD request
|
|
|
// but only to fetch the first nonce.
|
|
// but only to fetch the first nonce.
|
|
@@ -1072,7 +1072,7 @@ func TestRetryPostJWS(t *testing.T) {
|
|
|
var count int
|
|
var count int
|
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
count++
|
|
count++
|
|
|
- w.Header().Set("replay-nonce", fmt.Sprintf("nonce%d", count))
|
|
|
|
|
|
|
+ w.Header().Set("Replay-Nonce", fmt.Sprintf("nonce%d", count))
|
|
|
if r.Method == "HEAD" {
|
|
if r.Method == "HEAD" {
|
|
|
// We expect the client to do 2 head requests to fetch
|
|
// We expect the client to do 2 head requests to fetch
|
|
|
// nonces, one to start and another after getting badNonce
|
|
// nonces, one to start and another after getting badNonce
|