From 7de72eede636b225fdc8444a1ef90b4ea4d9ea82 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Fri, 10 Aug 2018 15:24:45 -0400 Subject: [PATCH] WFE2: Add unit tests for draft-12/draft-13 intercompat. (#3816) The implementation of the `features.ACME13KeyRollover` flag was written with the intent to allow client developers to send both the `"newKey"` and `"oldKey"` and be interoperable between both feature flag states. We should have an explicit unit test for this to be sure it works as intended. --- wfe2/wfe_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/wfe2/wfe_test.go b/wfe2/wfe_test.go index 8ed618f83..7d1659d4e 100644 --- a/wfe2/wfe_test.go +++ b/wfe2/wfe_test.go @@ -2127,6 +2127,22 @@ func TestKeyRollover(t *testing.T) { }`, NewKey: newKeyPriv, }, + { + Name: "Valid key rollover request, added ACME13KeyRollover compat", + Payload: `{"newKey":` + string(newJWKJSON) + `, "oldKey":` + test1KeyPublicJSON + `, "account":"http://localhost/acme/acct/1"}`, + ExpectedResponse: `{ + "id": 1, + "key": ` + string(newJWKJSON) + `, + "contact": [ + "mailto:person@mail.com" + ], + "agreement": "http://example.invalid/terms", + "initialIp": "", + "createdAt": "0001-01-01T00:00:00Z", + "status": "valid" + }`, + NewKey: newKeyPriv, + }, { Name: "ACME13KeyRollover, legacy rollover request", ACME13KeyRollover: true, @@ -2191,6 +2207,23 @@ func TestKeyRollover(t *testing.T) { }`, NewKey: newKeyPriv, }, + { + Name: "ACME13KeyRollover, Valid key rollover request, legacy compat", + ACME13KeyRollover: true, + Payload: `{"oldKey":` + test1KeyPublicJSON + `, "newKey":` + string(newJWKJSON) + `, "account":"http://localhost/acme/acct/1"}`, + ExpectedResponse: `{ + "id": 1, + "key": ` + string(newJWKJSON) + `, + "contact": [ + "mailto:person@mail.com" + ], + "agreement": "http://example.invalid/terms", + "initialIp": "", + "createdAt": "0001-01-01T00:00:00Z", + "status": "valid" + }`, + NewKey: newKeyPriv, + }, } for _, tc := range testCases {