Skip to content
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

Add explicit error message (SOAP response) #1007

Merged
merged 3 commits into from
Dec 14, 2023
Merged

Conversation

sfraigneau
Copy link
Contributor

Description

Return an explicit message when an error occurs while mocking soap response

Note : The error message is returned as the response body like others. Using Spring exception handler may be more appropriate.

Related issue(s)

#895

@lbroudoux
Copy link
Member

Thanks @sfraigneau, for this PR!

I marked it as a part of #895 because only deals with Soap mocks. That's a great first step!

@lbroudoux lbroudoux added this to the 1.8.1 milestone Dec 1, 2023
Copy link
Member

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR. I had a few comments and questions I have on status code... Looking forward to getting your opinions on this!

Also I have to figure out how to remove those 3 commits that were already approved into another PR now merged. Do you have any idea?

Comment on lines 143 to 145
if (action == null || action.length() > 0) {
action = operationName;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this condition purpose... At this point of flow, we haven't found rOperation using the action so we're looking at operation extracted from the body payload.
I think we could directly set action = operationName no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the requested action in header takes precedence over the requested action in the body, I return the header one if the client asks for action in both header and body.
I set the action variable only in case the client asks for action in body only

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But action == null || action.length() > 0 is only true if action is null or not empty, right?
So we have 2 cases here:

  • client didn't ask for action in header (action is null because not found in header)
  • client did ask for action in header (action is not empty as found in header).

Are you sure it's a ||? I don't see why we couldn't just have action = operationName... sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right, the condition was wrong. It should be :
action == null || action.length() == 0

I changed the way to check by using hasText from Spring utils. It is more readable.

if (wsdlResources.isEmpty()) {
return new ResponseEntity<String>(
String.format("The service %s with version %s does not have a wsdl!", serviceName, version),
HttpStatus.NOT_FOUND);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the check but we need to have a decision on status code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a 400 here. My point was that the wsdl of the service is part of the resource and it does not exist

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if 412 wouldn't be more appropriate: a validation precondition set by the client cannot be fulfilled...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

412 is good for me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you thus change it to 412 above? Then I think we'll be good to merge!

@sfraigneau
Copy link
Contributor Author

Also I have to figure out how to remove those 3 commits that were already approved into another PR now merged. Do you have any idea?

I forgot to sign-ff my commit and after force push, these commits appear in the PR. No idea why
I will redo the PR starting from the microcks branch. I think it's the best option ;)

@lbroudoux
Copy link
Member

Also I have to figure out how to remove those 3 commits that were already approved into another PR now merged. Do you have any idea?

I forgot to sign-ff my commit and after force push, these commits appear in the PR. No idea why I will redo the PR starting from the microcks branch. I think it's the best option ;)

Maybe rebasing your branch on 1.8.x and force-pushing the PR could do the trick?

Copy link
Member

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 change away from merge! Thanks!

if (wsdlResources.isEmpty()) {
return new ResponseEntity<String>(
String.format("The service %s with version %s does not have a wsdl!", serviceName, version),
HttpStatus.NOT_FOUND);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you thus change it to 412 above? Then I think we'll be good to merge!

@lbroudoux
Copy link
Member

Thanks a lot @sfraigneau !

@lbroudoux lbroudoux merged commit e49e11e into microcks:1.8.x Dec 14, 2023
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants