LoginRequestStatus.Message should be a pointer since it is +optional

Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
Andrew Keesler 2020-08-14 09:18:31 -04:00
parent 6e46ff345a
commit c6f1defa9d
No known key found for this signature in database
GPG Key ID: 27CE0444346F9413
8 changed files with 26 additions and 8 deletions

View File

@ -202,10 +202,11 @@ func traceFailureWithError(t *trace.Trace, failureType string, err error) {
}
func failureResponse() *placeholderapi.LoginRequest {
m := "authentication failed"
return &placeholderapi.LoginRequest{
Status: placeholderapi.LoginRequestStatus{
Credential: nil,
Message: "authentication failed",
Message: &m,
},
}
}

View File

@ -123,7 +123,6 @@ func TestCreate(t *testing.T) {
ClientCertificateData: "test-cert",
ClientKeyData: "test-key",
},
Message: "",
},
})
r.Equal(requestToken, webhook.calledWithToken)
@ -490,7 +489,7 @@ func requireSuccessfulResponseWithAuthenticationFailureMessage(t *testing.T, err
require.Equal(t, response, &placeholderapi.LoginRequest{
Status: placeholderapi.LoginRequestStatus{
Credential: nil,
Message: "authentication failed",
Message: stringPtr("authentication failed"),
},
})
}
@ -502,3 +501,7 @@ func successfulIssuer(ctrl *gomock.Controller) CertIssuer {
Return([]byte("test-cert"), []byte("test-key"), nil)
return issuer
}
func stringPtr(s string) *string {
return &s
}

View File

@ -59,7 +59,7 @@ type LoginRequestStatus struct {
// An error message will be returned for an unsuccessful login request.
// +optional
Message string
Message *string
}
// +genclient

View File

@ -59,7 +59,7 @@ type LoginRequestStatus struct {
// An error message will be returned for an unsuccessful login request.
// +optional
Message string `json:"message,omitempty"`
Message *string `json:"message,omitempty"`
}
// +genclient

View File

@ -202,7 +202,7 @@ func Convert_placeholder_LoginRequestSpec_To_v1alpha1_LoginRequestSpec(in *place
func autoConvert_v1alpha1_LoginRequestStatus_To_placeholder_LoginRequestStatus(in *LoginRequestStatus, out *placeholder.LoginRequestStatus, s conversion.Scope) error {
out.Credential = (*placeholder.LoginRequestCredential)(unsafe.Pointer(in.Credential))
out.User = (*placeholder.User)(unsafe.Pointer(in.User))
out.Message = in.Message
out.Message = (*string)(unsafe.Pointer(in.Message))
return nil
}
@ -214,7 +214,7 @@ func Convert_v1alpha1_LoginRequestStatus_To_placeholder_LoginRequestStatus(in *L
func autoConvert_placeholder_LoginRequestStatus_To_v1alpha1_LoginRequestStatus(in *placeholder.LoginRequestStatus, out *LoginRequestStatus, s conversion.Scope) error {
out.Credential = (*LoginRequestCredential)(unsafe.Pointer(in.Credential))
out.User = (*User)(unsafe.Pointer(in.User))
out.Message = in.Message
out.Message = (*string)(unsafe.Pointer(in.Message))
return nil
}

View File

@ -125,6 +125,11 @@ func (in *LoginRequestStatus) DeepCopyInto(out *LoginRequestStatus) {
*out = new(User)
(*in).DeepCopyInto(*out)
}
if in.Message != nil {
in, out := &in.Message, &out.Message
*out = new(string)
**out = **in
}
return
}

View File

@ -125,6 +125,11 @@ func (in *LoginRequestStatus) DeepCopyInto(out *LoginRequestStatus) {
*out = new(User)
(*in).DeepCopyInto(*out)
}
if in.Message != nil {
in, out := &in.Message, &out.Message
*out = new(string)
**out = **in
}
return
}

View File

@ -155,7 +155,7 @@ func TestFailedLoginRequestWhenTheRequestIsValidButTheTokenDoesNotAuthenticateTh
require.Empty(t, response.Spec)
require.Nil(t, response.Status.Credential)
require.Nil(t, response.Status.User)
require.Equal(t, "authentication failed", response.Status.Message)
require.Equal(t, stringPtr("authentication failed"), response.Status.Message)
}
func TestLoginRequest_ShouldFailWhenRequestDoesNotIncludeToken(t *testing.T) {
@ -178,3 +178,7 @@ func TestLoginRequest_ShouldFailWhenRequestDoesNotIncludeToken(t *testing.T) {
require.Empty(t, response.Spec)
require.Nil(t, response.Status.Credential)
}
func stringPtr(s string) *string {
return &s
}