Exemplo n.º 1
0
    public async Task Updates_Auth_Header()
    {
        var client  = new RestClient();
        var request = new RestRequest();

        var authenticator = new JwtAuthenticator(_expectedAuthHeaderContent);

        client.Authenticator = authenticator;
        await client.Authenticator.Authenticate(client, request);

        authenticator.SetBearerToken("second_header_auth_token");
        await client.Authenticator.Authenticate(client, request);

        var paramList = request.Parameters.Where(p => p.Name.Equals(KnownHeaders.Authorization)).ToList();

        Assert.Single(paramList);

        var authParam = paramList[0];

        Assert.True(authParam.Type == ParameterType.HttpHeader);
        Assert.NotEqual(_expectedAuthHeaderContent, authParam.Value);
        Assert.Equal("Bearer second_header_auth_token", authParam.Value);
    }
Exemplo n.º 2
0
        public void Updates_Auth_Header()
        {
            var client  = new RestClient();
            var request = new RestRequest();

            var authenticator = new JwtAuthenticator(_expectedAuthHeaderContent);

            client.Authenticator = authenticator;
            client.Authenticator.Authenticate(client, request);

            authenticator.SetBearerToken("second_header_auth_token");
            client.Authenticator.Authenticate(client, request);

            var paramList = request.Parameters.FindAll(p => p.Name.Equals("Authorization"));

            Assert.AreEqual(1, paramList.Count);

            var authParam = paramList[0];

            Assert.True(authParam.Type == ParameterType.HttpHeader);
            Assert.AreNotEqual(_expectedAuthHeaderContent, authParam.Value);
            Assert.AreEqual("Bearer second_header_auth_token", authParam.Value);
        }