public void BearerToken_JsonContent_TokenRecognized() { string content = "{\"authentication\":{\"token\":\"" + BearerExample + "\",\"bid\":9,\"umail\":\"[email protected]\"}}"; Response response = new Response(System.Net.HttpStatusCode.OK, content); BearerTokenizer tokenizer = new BearerTokenizer(); TokenCollection tokens = tokenizer.ExtractTokens(response); BearerToken match = new BearerToken(BearerExample); Assert.True(tokens.ContainsExactMatch(match) != null); }
public void BearerToken_RequestHeaders_TokenReplaced() { Request initializeCart = new Request(new Uri(@"http://localhost/api/BasketItems/"), HttpMethod.Post); initializeCart.Content = "{\"ProductId\":24,\"BasketId\":\"20\",\"quantity\":1}"; initializeCart.Headers.Add("Authorization", new List <string> { $"Bearer {BearerExample}" }); BearerTokenizer tokenizer = new BearerTokenizer(); TokenCollection tokens = tokenizer.ExtractTokens(initializeCart); List <IToken> match = tokens.GetByName("BearerToken"); Assert.Single(match); match[0].ReplaceValue(initializeCart, "testresult"); Assert.Equal("Bearer testresult", initializeCart.Headers["Authorization"][0]); }