-
Notifications
You must be signed in to change notification settings - Fork 13
Resiliency to newly-added capabilities #32
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
base: master
Are you sure you want to change the base?
Resiliency to newly-added capabilities #32
Conversation
…ebuggerDisplay to represent unknown capabilities in the returned string. Made a copy of the Allowed class called AllowedRaw.cs in Bytewizer.Backblaze.Client.Internal that represents capabilities as a list of plain strings, with method ParseCapabilities to transform instances into the original Allowed class. Updated LangVersion in Backblaze.Client.csproj to 8.0 to allow the use of the coalescing assignment operator. Made a copy of AuthorizedAccountResponse.cs in Bytewizer.Backblaze.Client.Internal that uses AllowedRaw instead of Allowed. Updated AuthorizeAccountAsync to use AuthorizeAccountResponseRaw for the actual request and then convert the result to the regular AuthorizedAccountResponse structure, with ParseCapabilities splitting off unknown capabilities.
@logiclrd Thanks again for your contribution. I will take a look that these pull requests this weekend. You don't by any chance have any test cases for these additions? |
I tested them by hand, by temporarily undoing the previous PR that added the new capabilities for bucket notifications. I'll have to look into whether there's a simple way to test this from the other side... |
- Added an AssemblyInfo class to Backblaze.Client.csproj with an InternalsVisibleTo attribute allowing Backblaze.Tests.Unit access to internal members. - Added references from Backblaze.Tests.Unit.csproj to NSubstitute, Bogus, FluentAssertions and ASP.NET Core (in order to use Kestrel). - Added class TestServer.cs to Backblaze.Tests.Unit to create an in-process hosted web server for testing purposes. - Added text fixture class ApiClientFixture.cs to Backblaze.Tests.Unit with tests of the AuthorizeAccountAync method, including specifically Capabilities Resiliency. Moved the initialization of Allowed.Capabilities and Allowed.UnknownCapabilities out of the loop in AllowedRaw.ParseCapabilities and added explicit initialization for Capabilities.
…o use explicit strings instead of Faker-generated strings for unknown capability names, since there is a tiny change of faker.Random.Words(3) returning the same string twice.
@microcompiler There you go. :-) |
…e for the Backblaze.Tests.Unit project.
Backblaze periodically adds new "capabilities" to the B2 API. The current strategy for parsing the models associated with successful logins requires all capabilities to be recognized. This breaks the library every time it happens. This PR aims to provide resiliency to this situation, by making the raw parsing of the "Allowed" structure in new type
AllowedRaw
just use a list of strings for the capabilities, and then later sorting them into known and unknown capabilities for the actualAllowed
object returned by theConnect
call.