From 76618558ae93c610f3f713153da71c57397f292b Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Tue, 19 Mar 2019 15:27:41 -0700 Subject: [PATCH] Improve unit tests. --- authority/provisioner/jwk_test.go | 6 ++++++ authority/provisioner/oidc_test.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/authority/provisioner/jwk_test.go b/authority/provisioner/jwk_test.go index f2ddd94d..7a2dc50c 100644 --- a/authority/provisioner/jwk_test.go +++ b/authority/provisioner/jwk_test.go @@ -78,6 +78,12 @@ func TestJWK_Init(t *testing.T) { err: errors.New("provisioner key cannot be empty"), } }, + "fail-bad-claims": func(t *testing.T) ProvisionerValidateTest { + return ProvisionerValidateTest{ + p: &JWK{Name: "foo", Type: "bar", Key: &jose.JSONWebKey{}, audiences: testAudiences, Claims: &Claims{DefaultTLSDur: &Duration{0}}}, + err: errors.New("claims: DefaultTLSCertDuration must be greater than 0"), + } + }, "ok": func(t *testing.T) ProvisionerValidateTest { return ProvisionerValidateTest{ p: &JWK{Name: "foo", Type: "bar", Key: &jose.JSONWebKey{}, audiences: testAudiences}, diff --git a/authority/provisioner/oidc_test.go b/authority/provisioner/oidc_test.go index 39dcbe29..b70f44e4 100644 --- a/authority/provisioner/oidc_test.go +++ b/authority/provisioner/oidc_test.go @@ -64,6 +64,9 @@ func TestOIDC_Init(t *testing.T) { config := Config{ Claims: globalProvisionerClaims, } + badClaims := &Claims{ + DefaultTLSDur: &Duration{0}, + } type fields struct { Type string @@ -93,6 +96,7 @@ func TestOIDC_Init(t *testing.T) { {"no-client-id", fields{"oidc", "name", "", "client-secret", srv.URL + "/openid-configuration", nil, nil, nil}, args{config}, true}, {"no-configuration", fields{"oidc", "name", "client-id", "client-secret", "", nil, nil, nil}, args{config}, true}, {"bad-configuration", fields{"oidc", "name", "client-id", "client-secret", srv.URL, nil, nil, nil}, args{config}, true}, + {"bad-claims", fields{"oidc", "name", "client-id", "client-secret", srv.URL + "/openid-configuration", badClaims, nil, nil}, args{config}, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {