-
Notifications
You must be signed in to change notification settings - Fork 171
Align Cloud Controller response handling with Spring, improve tests #1521
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9d1b01a
Align Cloud Controller response handling with Spring, improve tests
TimHess 78bdc9b
code cleanup
TimHess 88c6c49
remove catching timeouts, add log assertions
TimHess e662a7b
catch cancel/timeout again, with trace-log and rethrow
TimHess 17ab4d2
PR feedback
TimHess 6606643
Update src/Management/test/Endpoint.Test/Actuators/CloudFoundry/Permi…
TimHess 8d28290
PR feedback
TimHess 2145031
back to not catching cancellation, use real web host and other test c…
TimHess 505a278
Catch timeouts on permissions check
TimHess df9b462
naming things, use typeof for logs, comments
TimHess 93b330b
remove inner log, formatting
TimHess ff1d780
catch HttpRequestException
TimHess 121e512
update middleware test expectations
TimHess e60cc4e
adjust a log level, more detail in test exception
TimHess 2a08c42
format
TimHess File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Management/test/Endpoint.Test/Actuators/CloudFoundry/CloudControllerPermissionsMock.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the Apache 2.0 License. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System.Net; | ||
| using RichardSzalay.MockHttp; | ||
| using Steeltoe.Common.TestResources; | ||
|
|
||
| namespace Steeltoe.Management.Endpoint.Test.Actuators.CloudFoundry; | ||
|
|
||
| internal static class CloudControllerPermissionsMock | ||
| { | ||
| internal static DelegateToMockHttpClientHandler GetHttpMessageHandler() | ||
| { | ||
| var httpClientHandler = new DelegateToMockHttpClientHandler(); | ||
|
|
||
| httpClientHandler.Mock.When(HttpMethod.Get, "https://example.api.com/v2/apps/unavailable/permissions") | ||
| .Respond(HttpStatusCode.ServiceUnavailable, "application/json", "{}"); | ||
|
|
||
| httpClientHandler.Mock.When(HttpMethod.Get, "https://example.api.com/v2/apps/not-found/permissions") | ||
| .Respond(HttpStatusCode.NotFound, "application/json", "{}"); | ||
|
|
||
| httpClientHandler.Mock.When(HttpMethod.Get, "https://example.api.com/v2/apps/unauthorized/permissions") | ||
| .Respond(HttpStatusCode.Unauthorized, "application/json", "{}"); | ||
|
|
||
| httpClientHandler.Mock.When(HttpMethod.Get, "https://example.api.com/v2/apps/forbidden/permissions") | ||
| .Respond(HttpStatusCode.Forbidden, "application/json", "{}"); | ||
|
|
||
| httpClientHandler.Mock.When(HttpMethod.Get, "https://example.api.com/v2/apps/timeout/permissions") | ||
| .Throw(new OperationCanceledException(null, new TimeoutException())); | ||
|
|
||
| httpClientHandler.Mock.When(HttpMethod.Get, "https://example.api.com/v2/apps/exception/permissions") | ||
| .Throw(new HttpRequestException(HttpRequestError.NameResolutionError)); | ||
|
|
||
| httpClientHandler.Mock.When(HttpMethod.Get, "https://example.api.com/v2/apps/no_sensitive_data/permissions").Respond(HttpStatusCode.OK, | ||
| "application/json", """{"read_sensitive_data": false, "read_basic_data": true}"""); | ||
|
|
||
| httpClientHandler.Mock.When(HttpMethod.Get, "https://example.api.com/v2/apps/success/permissions").Respond(HttpStatusCode.OK, "application/json", | ||
| """{"read_sensitive_data": true, "read_basic_data": true}"""); | ||
|
|
||
| return httpClientHandler; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.