Skip to content

Commit

Permalink
Merge pull request #217 from munnerz/automated-cherry-pick-of-#214-#215
Browse files Browse the repository at this point in the history
…-upstream-release-0.2

Automatic merge from submit-queue.

Automated cherry pick of #214 #215

Cherry pick of #214 #215 on release-0.2.

#214: Update for v0.2.2
#215: Fix checking for expired ACME authorizations
  • Loading branch information
jetstack-ci-bot committed Dec 1, 2017
2 parents c61c1cc + 67560ff commit 4dac873
Show file tree
Hide file tree
Showing 17 changed files with 1,415 additions and 6 deletions.
10 changes: 8 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contrib/charts/cert-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The following tables lists the configurable parameters of the cert-manager chart
| Parameter | Description | Default |
| ---------------------- | --------------------------------------- | ---------------------------------------------- |
| `image.repository` | Image repository | `quay.io/jetstack/cert-manager-controller` |
| `image.tag` | Image tag | `v0.2.1` |
| `image.tag` | Image tag | `v0.2.2` |
| `image.pullPolicy` | Image pull policy | `Always` |
| `replicaCount` | Number of cert-manager replicas | `1` |
| `createCustomResource` | Create CRD/TPR with this release | `true` |
Expand Down
4 changes: 2 additions & 2 deletions contrib/charts/cert-manager/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ replicaCount: 1

image:
repository: quay.io/jetstack/cert-manager-controller
tag: v0.2.1
tag: v0.2.2
pullPolicy: Always

createCustomResource: true
Expand All @@ -30,5 +30,5 @@ ingressShim:
repository: quay.io/jetstack/cert-manager-ingress-shim
# Defaults to image.tag.
# You should only change this if you know what you are doing!
# tag: v0.2.1
# tag: v0.2.2
pullPolicy: Always
5 changes: 4 additions & 1 deletion docs/examples/cert-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ spec:
spec:
containers:
- name: cert-manager
image: quay.io/jetstack/cert-manager-controller:v0.2.1
image: quay.io/jetstack/cert-manager-controller:v0.2.2
imagePullPolicy: Always
- name: ingress-shim
image: quay.io/jetstack/cert-manager-ingress-shim:v0.2.2
imagePullPolicy: Always
6 changes: 6 additions & 0 deletions pkg/issuer/acme/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ func checkAuthorization(ctx context.Context, cl *acme.Client, uri string) (bool,
a, err := cl.GetAuthorization(ctx, uri)

if err != nil {
if err, ok := err.(*acme.Error); ok {
// response code is 404 when authorization has expired
if err.StatusCode == 404 {
return false, nil
}
}
return false, err
}

Expand Down
99 changes: 99 additions & 0 deletions pkg/issuer/acme/prepare_test.go
Original file line number Diff line number Diff line change
@@ -1 +1,100 @@
package acme

import (
"context"
"io/ioutil"
"net/http"
"strings"
"testing"

"golang.org/x/crypto/acme"
"gopkg.in/jarcoal/httpmock.v1"
)

func TestCheckAuthorization(t *testing.T) {
type testT struct {
name string
mockStatusCode int
mockResponse string
ctx context.Context
uri string
expected bool
err bool
}
tests := []testT{
{
name: "should return no error for 404 return code",
mockStatusCode: 404,
mockResponse: `{
"type": "urn:acme:error:malformed",
"detail": "Expired authorization",
"status": 404
}`,
uri: "http://testuri",
expected: false,
err: false,
},
{
name: "should return valid for a 200 return code",
mockStatusCode: 200,
mockResponse: `{
"status": "valid"
}`,
uri: "http://testuri",
expected: true,
err: false,
},
{
name: "should return invalid but no error for any status that isn't 'valid'",
mockStatusCode: 200,
mockResponse: `{
"status": "invalid"
}`,
uri: "http://testuri",
expected: false,
err: false,
},
{
name: "should return an error for an invalid response",
mockStatusCode: 500,
// invalid response body
mockResponse: `{
"type": "urn:acme:error:malformed",
"detail": "Fake error",
"status": 500
}`,
uri: "http://testuri",
expected: false,
err: true,
},
}
testFn := func(test testT) func(t *testing.T) {
return func(t *testing.T) {
mock := httpmock.NewMockTransport()
mock.RegisterResponder("GET", test.uri, httpmock.ResponderFromResponse(&http.Response{
StatusCode: test.mockStatusCode,
Body: ioutil.NopCloser(strings.NewReader(test.mockResponse)),
}))
ctx := test.ctx
if ctx == nil {
ctx = context.Background()
}
cl := &acme.Client{
HTTPClient: &http.Client{Transport: mock},
}
valid, err := checkAuthorization(ctx, cl, test.uri)
if err != nil && !test.err {
t.Errorf("expected no error, but got: %s", err)
}
if err == nil && test.err {
t.Errorf("expected error, but got no error")
}
if valid != test.expected {
t.Errorf("expected checkAuthorization to return %v, but got %v", test.expected, valid)
}
}
}
for _, test := range tests {
t.Run(test.name, testFn(test))
}
}
22 changes: 22 additions & 0 deletions vendor/gopkg.in/jarcoal/httpmock.v1/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions vendor/gopkg.in/jarcoal/httpmock.v1/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions vendor/gopkg.in/jarcoal/httpmock.v1/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

116 changes: 116 additions & 0 deletions vendor/gopkg.in/jarcoal/httpmock.v1/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4dac873

Please sign in to comment.