public void Generate_Valid_Basic_Authentication_Token()
        {
            // Arrange
            String expectedResult = "VXNlcm5hbWU6UGFzc3dvcmQ=";
            String result         = String.Empty;
            String username       = "******";
            String password       = "******";

            // Act
            result = WebAuthHelper.GenerateBasicAuthString(username, password);

            // Assert
            Assert.Equal(expectedResult, result);
        }
        public ApiResponse <String> GenerateBasicAuth([FromBody] BasicAuthTokenRequest request)
        {
            // Create a new response object
            ApiResponse <String> response = new ApiResponse <string>()
            {
                Data = String.Empty, Success = false
            };

            // Check for input
            if ((request.Username ?? String.Empty) == String.Empty)
            {
                response.Messages.Add("No username provided");
            }

            if ((request.Password ?? String.Empty) == String.Empty)
            {
                response.Messages.Add("No password provided");
            }

            // No errors?
            if (response.Messages.Count == 0)
            {
                // Try and get the token from the helper
                response.Data = WebAuthHelper.GenerateBasicAuthString(request.Username, request.Password);
                if (response.Data == String.Empty)
                {
                    response.Messages.Add("No token generated");
                }

                // Success?
                response.Success = (response.Messages.Count == 0) &&
                                   ((response.Data ?? String.Empty) != String.Empty);
            }

            // Send the result back
            return(response);
        }