@@ -374,7 +374,7 @@ func TestHandleFunc(t *testing.T) {
374374 {[]string {"GET" , "POST" }, "POST" , true },
375375 {[]string {"GET" }, "" , false },
376376 {[]string {"GET" }, "POST" , false },
377- {[]string {"GET" }, "OPTIONS" , false }, // TODO, #469
377+ {[]string {"GET" }, "OPTIONS" , false }, // TODO, #469
378378 {[]string {"GET" }, "MAKE-COFFEE" , false }, // 405, or 418?
379379 } {
380380 runWrappedHandler (& http.Request {Method : c .reqMethod }, c .allowed ... )
@@ -408,7 +408,8 @@ func TestHandleFunc(t *testing.T) {
408408
409409func TestStandardHeaders (t * testing.T ) {
410410 wfe := setupWFE (t )
411- mux := wfe .Handler ()
411+ mux , err := wfe .Handler ()
412+ test .AssertNotError (t , err , "Failed to marshal directory to JSON" )
412413
413414 cases := []struct {
414415 path string
@@ -464,11 +465,29 @@ func TestIndex(t *testing.T) {
464465 test .AssertEquals (t , responseWriter .Body .String (), "404 page not found\n " )
465466}
466467
468+ func TestDirectory (t * testing.T ) {
469+ wfe := setupWFE (t )
470+ wfe .BaseURL = "http://localhost:4300"
471+ mux , err := wfe .Handler ()
472+ test .AssertNotError (t , err , "Failed to marshal directory to JSON" )
473+
474+ responseWriter := httptest .NewRecorder ()
475+
476+ url , _ := url .Parse ("/directory" )
477+ mux .ServeHTTP (responseWriter , & http.Request {
478+ Method : "GET" ,
479+ URL : url ,
480+ })
481+ test .AssertEquals (t , responseWriter .Code , http .StatusOK )
482+ test .AssertEquals (t , responseWriter .Body .String (), `{"new-authz":"http://localhost:4300/acme/new-authz","new-cert":"http://localhost:4300/acme/new-cert","new-reg":"http://localhost:4300/acme/new-reg","revoke-cert":"http://localhost:4300/acme/revoke-cert"}` )
483+ }
484+
467485// TODO: Write additional test cases for:
468486// - RA returns with a failure
469487func TestIssueCertificate (t * testing.T ) {
470488 wfe := setupWFE (t )
471- mux := wfe .Handler ()
489+ mux , err := wfe .Handler ()
490+ test .AssertNotError (t , err , "Failed to marshal directory to JSON" )
472491
473492 // TODO: Use a mock RA so we can test various conditions of authorized, not authorized, etc.
474493 ra := ra .NewRegistrationAuthorityImpl ()
@@ -649,7 +668,8 @@ func TestChallenge(t *testing.T) {
649668
650669func TestNewRegistration (t * testing.T ) {
651670 wfe := setupWFE (t )
652- mux := wfe .Handler ()
671+ mux , err := wfe .Handler ()
672+ test .AssertNotError (t , err , "Failed to marshal directory to JSON" )
653673
654674 wfe .RA = & MockRegistrationAuthority {}
655675 wfe .SA = & MockSA {}
@@ -893,7 +913,8 @@ func TestRevokeCertificateAlreadyRevoked(t *testing.T) {
893913
894914func TestAuthorization (t * testing.T ) {
895915 wfe := setupWFE (t )
896- mux := wfe .Handler ()
916+ mux , err := wfe .Handler ()
917+ test .AssertNotError (t , err , "Failed to marshal directory to JSON" )
897918
898919 wfe .RA = & MockRegistrationAuthority {}
899920 wfe .SA = & MockSA {}
@@ -972,13 +993,14 @@ func TestAuthorization(t *testing.T) {
972993 test .AssertEquals (t , responseWriter .Body .String (), "{\" identifier\" :{\" type\" :\" dns\" ,\" value\" :\" test.com\" }}" )
973994
974995 var authz core.Authorization
975- err : = json .Unmarshal ([]byte (responseWriter .Body .String ()), & authz )
996+ err = json .Unmarshal ([]byte (responseWriter .Body .String ()), & authz )
976997 test .AssertNotError (t , err , "Couldn't unmarshal returned authorization object" )
977998}
978999
9791000func TestRegistration (t * testing.T ) {
9801001 wfe := setupWFE (t )
981- mux := wfe .Handler ()
1002+ mux , err := wfe .Handler ()
1003+ test .AssertNotError (t , err , "Failed to marshal directory to JSON" )
9821004
9831005 wfe .RA = & MockRegistrationAuthority {}
9841006 wfe .SA = & MockSA {}
0 commit comments