public async Task <string> GetBricksetApiKey(Identification allMyBricksIdentification) { var client = new FlurlClient().Configure(settings => settings.HttpClientFactory = new HmacDelegatingHandlerHttpClientFactory()); var apiKeyRequest = allMyBricksIdentification.ToApiKeyRequest(); apiKeyRequest.KeyOption = RandomKeyOptionGenerator.GetRandomKeyOption(); var responseApiKeyResult = await _allMyBricksOnboardingApiKeyServiceUrl .AppendPathSegment(Constants.AllMyBricksOnboardingApiKeyServiceBricksetMethod) .WithClient(client) .PostJsonAsync(apiKeyRequest) .ReceiveString().ConfigureAwait(false); return(JWT.Decode(responseApiKeyResult, Encoding.UTF8.GetBytes(allMyBricksIdentification.RegistrationHash.ToCharArray()), (JwsAlgorithm)apiKeyRequest.KeyOption)); }
public void GetRandomKeyOption() { const int count = 1000; var algorithmTypeEnumList = new List <AlgorithmType>(); for (int i = 0; i < count; i++) { var next = RandomKeyOptionGenerator.GetRandomKeyOption(); algorithmTypeEnumList.Add(next); } Check.That(algorithmTypeEnumList) .CountIs(count) .And .ContainsOnlyElementsThatMatch(algoType => algoType != 0); }