Beispiel #1
0
        public void When_Passing_Empty_AuthenticationHeaderParameter_Then_Empty_Result_Is_Returned()
        {
            var authenticationHeaderValue = new AuthenticationHeaderValue("Bearer", string.Empty);

            var result = authenticationHeaderValue.GetAuthenticateInstruction(null);

            Assert.True(string.IsNullOrWhiteSpace(result.ClientIdFromAuthorizationHeader));
            Assert.True(string.IsNullOrWhiteSpace(result.ClientSecretFromAuthorizationHeader));
        }
Beispiel #2
0
        public void When_Passing_Not_Valid_Parameter_Then_Empty_Result_Is_Returned()
        {
            var parameter                 = "parameter";
            var encodedParameter          = parameter.Base64Encode();
            var authenticationHeaderValue = new AuthenticationHeaderValue("Bearer", encodedParameter);

            var result = authenticationHeaderValue.GetAuthenticateInstruction(null);

            Assert.True(string.IsNullOrWhiteSpace(result.ClientIdFromAuthorizationHeader));
            Assert.True(string.IsNullOrWhiteSpace(result.ClientSecretFromAuthorizationHeader));
        }
Beispiel #3
0
        public void When_Passing_Valid_Parameter_Then_Valid_AuthenticateInstruction_Is_Returned()
        {
            const string clientId                  = "clientId";
            const string clientSecret              = "clientSecret";
            var          parameter                 = $"{clientId}:{clientSecret}";
            var          encodedParameter          = parameter.Base64Encode();
            var          authenticationHeaderValue = new AuthenticationHeaderValue("Basic", encodedParameter);

            var result = authenticationHeaderValue.GetAuthenticateInstruction(null);

            Assert.Equal(clientId, result.ClientIdFromAuthorizationHeader);
            Assert.Equal(clientSecret, result.ClientSecretFromAuthorizationHeader);
        }