From 6b5a2b17b51cb2641b1c464b58d7a737788da211 Mon Sep 17 00:00:00 2001 From: Ivan Bertona Date: Fri, 7 Feb 2020 15:25:27 -0500 Subject: [PATCH] Add challenge unmarshal test cases. --- acme/challenge_test.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/acme/challenge_test.go b/acme/challenge_test.go index bfcfb603..40466454 100644 --- a/acme/challenge_test.go +++ b/acme/challenge_test.go @@ -433,7 +433,7 @@ func TestChallengeUnmarshal(t *testing.T) { err: ServerInternalErr(errors.New("error unmarshaling challenge type: unexpected end of JSON input")), } }, - "fail/unexpected-type": func(t *testing.T) test { + "fail/unexpected-type-http": func(t *testing.T) test { httpCh, err := newHTTPCh() assert.FatalError(t, err) _httpCh, ok := httpCh.(*http01Challenge) @@ -446,6 +446,32 @@ func TestChallengeUnmarshal(t *testing.T) { err: ServerInternalErr(errors.New("unexpected challenge type foo")), } }, + "fail/unexpected-type-alpn": func(t *testing.T) test { + tlsALPNCh, err := newTLSALPNCh() + assert.FatalError(t, err) + _tlsALPNCh, ok := tlsALPNCh.(*tlsALPN01Challenge) + assert.Fatal(t, ok) + _tlsALPNCh.baseChallenge.Type = "foo" + b, err := json.Marshal(tlsALPNCh) + assert.FatalError(t, err) + return test{ + chb: b, + err: ServerInternalErr(errors.New("unexpected challenge type foo")), + } + }, + "fail/unexpected-type-dns": func(t *testing.T) test { + dnsCh, err := newDNSCh() + assert.FatalError(t, err) + _tlsALPNCh, ok := dnsCh.(*dns01Challenge) + assert.Fatal(t, ok) + _tlsALPNCh.baseChallenge.Type = "foo" + b, err := json.Marshal(dnsCh) + assert.FatalError(t, err) + return test{ + chb: b, + err: ServerInternalErr(errors.New("unexpected challenge type foo")), + } + }, "ok/dns": func(t *testing.T) test { dnsCh, err := newDNSCh() assert.FatalError(t, err)