integration tests for oidcclientsecretrequest endpoint
Co-authored-by: Ryan Richard <richardry@vmware.com> Co-authored-by: Benjamin A. Petersen <ben@benjaminapetersen.me>
This commit is contained in:
parent
a7ca2cf2dd
commit
12b3079377
@ -206,6 +206,10 @@ func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation
|
|||||||
Namespace: req.Namespace,
|
Namespace: req.Namespace,
|
||||||
CreationTimestamp: r.timeNowFunc(),
|
CreationTimestamp: r.timeNowFunc(),
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: req.Spec.GenerateNewSecret,
|
||||||
|
RevokeOldSecrets: req.Spec.RevokeOldSecrets,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: secret,
|
GeneratedSecret: secret,
|
||||||
TotalClientSecrets: len(hashes),
|
TotalClientSecrets: len(hashes),
|
||||||
|
@ -688,6 +688,10 @@ func TestCreate(t *testing.T) {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
CreationTimestamp: fakeNow,
|
CreationTimestamp: fakeNow,
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: true,
|
||||||
|
RevokeOldSecrets: false,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: fakeHexEncodedRandomBytes,
|
GeneratedSecret: fakeHexEncodedRandomBytes,
|
||||||
TotalClientSecrets: 1,
|
TotalClientSecrets: 1,
|
||||||
@ -760,6 +764,10 @@ func TestCreate(t *testing.T) {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
CreationTimestamp: fakeNow,
|
CreationTimestamp: fakeNow,
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: true,
|
||||||
|
RevokeOldSecrets: false,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: fakeHexEncodedRandomBytes,
|
GeneratedSecret: fakeHexEncodedRandomBytes,
|
||||||
TotalClientSecrets: 3,
|
TotalClientSecrets: 3,
|
||||||
@ -822,6 +830,10 @@ func TestCreate(t *testing.T) {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
CreationTimestamp: fakeNow,
|
CreationTimestamp: fakeNow,
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: true,
|
||||||
|
RevokeOldSecrets: true,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: fakeHexEncodedRandomBytes,
|
GeneratedSecret: fakeHexEncodedRandomBytes,
|
||||||
TotalClientSecrets: 1,
|
TotalClientSecrets: 1,
|
||||||
@ -884,6 +896,10 @@ func TestCreate(t *testing.T) {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
CreationTimestamp: fakeNow,
|
CreationTimestamp: fakeNow,
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: false,
|
||||||
|
RevokeOldSecrets: true,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: "",
|
GeneratedSecret: "",
|
||||||
TotalClientSecrets: 1,
|
TotalClientSecrets: 1,
|
||||||
@ -961,6 +977,7 @@ func TestCreate(t *testing.T) {
|
|||||||
`failureType:secretStorage.Set,msg:OIDCClient client.oauth.pinniped.dev-some-client has too many secrets, spec.revokeOldSecrets must be true`,
|
`failureType:secretStorage.Set,msg:OIDCClient client.oauth.pinniped.dev-some-client has too many secrets, spec.revokeOldSecrets must be true`,
|
||||||
`END`,
|
`END`,
|
||||||
},
|
},
|
||||||
|
want: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "secret exists but oidcclient secret has too many hashes, fails to create when RevokeOldSecrets:false (greater than 5), secret is not updated",
|
name: "secret exists but oidcclient secret has too many hashes, fails to create when RevokeOldSecrets:false (greater than 5), secret is not updated",
|
||||||
@ -1207,6 +1224,10 @@ func TestCreate(t *testing.T) {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
CreationTimestamp: fakeNow,
|
CreationTimestamp: fakeNow,
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: false,
|
||||||
|
RevokeOldSecrets: true,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: "",
|
GeneratedSecret: "",
|
||||||
TotalClientSecrets: 0,
|
TotalClientSecrets: 0,
|
||||||
@ -1247,6 +1268,10 @@ func TestCreate(t *testing.T) {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
CreationTimestamp: fakeNow,
|
CreationTimestamp: fakeNow,
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: false,
|
||||||
|
RevokeOldSecrets: false,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: "",
|
GeneratedSecret: "",
|
||||||
TotalClientSecrets: 0,
|
TotalClientSecrets: 0,
|
||||||
@ -1307,6 +1332,10 @@ func TestCreate(t *testing.T) {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
CreationTimestamp: fakeNow,
|
CreationTimestamp: fakeNow,
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: false,
|
||||||
|
RevokeOldSecrets: false,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: "",
|
GeneratedSecret: "",
|
||||||
TotalClientSecrets: 2,
|
TotalClientSecrets: 2,
|
||||||
@ -1365,6 +1394,10 @@ func TestCreate(t *testing.T) {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
CreationTimestamp: fakeNow,
|
CreationTimestamp: fakeNow,
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: true,
|
||||||
|
RevokeOldSecrets: true,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: fakeHexEncodedRandomBytes,
|
GeneratedSecret: fakeHexEncodedRandomBytes,
|
||||||
TotalClientSecrets: 1,
|
TotalClientSecrets: 1,
|
||||||
@ -1430,6 +1463,10 @@ func TestCreate(t *testing.T) {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
CreationTimestamp: fakeNow,
|
CreationTimestamp: fakeNow,
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: true,
|
||||||
|
RevokeOldSecrets: true,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: fakeHexEncodedRandomBytes,
|
GeneratedSecret: fakeHexEncodedRandomBytes,
|
||||||
TotalClientSecrets: 1,
|
TotalClientSecrets: 1,
|
||||||
@ -1496,6 +1533,10 @@ func TestCreate(t *testing.T) {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
CreationTimestamp: fakeNow,
|
CreationTimestamp: fakeNow,
|
||||||
},
|
},
|
||||||
|
Spec: clientsecretapi.OIDCClientSecretRequestSpec{
|
||||||
|
GenerateNewSecret: true,
|
||||||
|
RevokeOldSecrets: true,
|
||||||
|
},
|
||||||
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
Status: clientsecretapi.OIDCClientSecretRequestStatus{
|
||||||
GeneratedSecret: fakeHexEncodedRandomBytes,
|
GeneratedSecret: fakeHexEncodedRandomBytes,
|
||||||
TotalClientSecrets: 1,
|
TotalClientSecrets: 1,
|
||||||
@ -1610,7 +1651,7 @@ func TestCreate(t *testing.T) {
|
|||||||
|
|
||||||
type readerAlwaysErrors struct{}
|
type readerAlwaysErrors struct{}
|
||||||
|
|
||||||
func (r readerAlwaysErrors) Read(p []byte) (n int, err error) {
|
func (r readerAlwaysErrors) Read(_ []byte) (n int, err error) {
|
||||||
return 0, errors.New("always errors")
|
return 0, errors.New("always errors")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user