-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BadRequest validation added to Kamus API #94
Conversation
@AleF83 bumb version please |
@@ -28,23 +29,28 @@ public EncryptController(IKeyManagement keyManagement) | |||
[Route("api/v1/encrypt")] | |||
public async Task<ActionResult> Encrypt([FromBody]EncryptRequest body) | |||
{ | |||
if (!ModelState.IsValid) | |||
{ | |||
return BadRequest("One of required fields doesn't present in request body."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log the validation error please
@@ -35,6 +35,11 @@ public DecryptController(IKubernetes kubernetes, IKeyManagement keyManagement) | |||
[Authorize(AuthenticationSchemes = "kubernetes")] | |||
public async Task<ActionResult> Decrypt([FromBody] DecryptRequest body) | |||
{ | |||
if (!ModelState.IsValid) | |||
{ | |||
return BadRequest("One of required fields doesn't present in request body."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log validation error please
See last commit. Do you mean that? |
I want to add some tests to blackbox. Something that isn't happy flow. |
sounds good, should be easy to do, need help? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just bump version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this should and can be a minor
Co-Authored-By: AleF83 <AlexanderFux83@gmail.com>
Co-Authored-By: AleF83 <AlexanderFux83@gmail.com>
I've added test case for BadRequest. Review once again please |
public string SerivceAccountName | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
[JsonProperty(PropertyName = "namespace", Required = Required.Always)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove the required?
Co-Authored-By: AleF83 <AlexanderFux83@gmail.com>
Co-Authored-By: AleF83 <AlexanderFux83@gmail.com>
Co-Authored-By: AleF83 <AlexanderFux83@gmail.com>
Co-Authored-By: AleF83 <AlexanderFux83@gmail.com>
@@ -125,5 +125,22 @@ public async Task AnonymousRequestToDecryptEndpointShouldFail() | |||
|
|||
Assert.Equal(HttpStatusCode.Unauthorized, result.StatusCode); | |||
} | |||
|
|||
[Fact] | |||
public async Task Encrypt_BadRequest_ShouldFail() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about decryptor tests?
Co-Authored-By: AleF83 <AlexanderFux83@gmail.com>
Close #93