Exemple #1
0
        public async Task SignAsync_WithUserVisibleDataFormat__ShouldPostToBankIdSign_WithJsonPayload()
        {
            // Arrange

            // Act
            await _bankIdApiClient.SignAsync(new SignRequest("1.1.1.1", "userVisibleData", "userVisibleDataFormat", new byte[1]));

            // Assert
            var request       = _messageHandlerMock.GetFirstArgumentOfFirstInvocation <HttpMessageHandler, HttpRequestMessage>();
            var contentString = await request.Content.ReadAsStringAsync();

            JsonTests.AssertProperty(contentString, "endUserIp", "1.1.1.1");
            JsonTests.AssertPropertyIsEmptyObject(contentString, "requirement");
            JsonTests.AssertProperty(contentString, "userVisibleData", "dXNlclZpc2libGVEYXRh");
            JsonTests.AssertProperty(contentString, "userVisibleDataFormat", "userVisibleDataFormat");
            JsonTests.AssertProperty(contentString, "userNonVisibleData", "AA==");
            JsonTests.AssertOnlyProperties(contentString, new[]
            {
                "endUserIp",
                "requirement",
                "userVisibleData",
                "userVisibleDataFormat",
                "userNonVisibleData"
            });
        }
Exemple #2
0
        public async Task AuthAsync_WithAuthRequest__ShouldHaveUserData()
        {
            //Arrange
            byte[] userNonVisibleData = Encoding.ASCII.GetBytes("Hello");
            string asBase64           = Convert.ToBase64String(userNonVisibleData);

            //Act
            await _bankIdApiClient.AuthAsync(new AuthRequest("1.1.1.1", null, null, "Hello", userNonVisibleData, "simpleMarkdownV1"));

            //Assert
            var request       = _messageHandlerMock.GetFirstArgumentOfFirstInvocation <HttpMessageHandler, HttpRequestMessage>();
            var contentString = await request.Content.ReadAsStringAsync();

            JsonTests.AssertProperty(contentString, "endUserIp", "1.1.1.1");
            JsonTests.AssertPropertyIsEmptyObject(contentString, "requirement");
            JsonTests.AssertProperty(contentString, "userVisibleData", asBase64);
            JsonTests.AssertProperty(contentString, "userNonVisibleData", asBase64);
            JsonTests.AssertProperty(contentString, "userVisibleDataFormat", "simpleMarkdownV1");
            JsonTests.AssertOnlyProperties(contentString, new[]
            {
                "endUserIp",
                "requirement",
                "userVisibleData",
                "userNonVisibleData",
                "userVisibleDataFormat"
            });
        }
Exemple #3
0
        public async Task AuthAsync_WithEndUserIp__ShouldPostJsonPayload_WithEndUserIp_AndNoPersonalNumber_AndRequirementAsEmptyObject()
        {
            // Arrange

            // Act
            await _bankIdApiClient.AuthAsync(new AuthRequest("1.1.1.1"));

            // Assert
            var request       = _messageHandlerMock.GetFirstArgumentOfFirstInvocation <HttpMessageHandler, HttpRequestMessage>();
            var contentString = await request.Content.ReadAsStringAsync();

            JsonTests.AssertProperty(contentString, "endUserIp", "1.1.1.1");
            JsonTests.AssertPropertyIsEmptyObject(contentString, "requirement");
            JsonTests.AssertOnlyProperties(contentString, new[]
            {
                "endUserIp",
                "requirement"
            });
        }
Exemple #4
0
        public async Task SignAsync_WithEndUserIp_AndPin__ShouldPostJsonPayload_WithEndUserIp_AndPersonalNumber_AndUserVisibleData_AndNoRequirements()
        {
            // Arrange

            // Act
            await _bankIdApiClient.SignAsync(new SignRequest("1.1.1.1", "userVisibleData", null, "201801012392"));

            // Assert
            var request       = _messageHandlerMock.GetFirstArgumentOfFirstInvocation <HttpMessageHandler, HttpRequestMessage>();
            var contentString = await request.Content.ReadAsStringAsync();

            JsonTests.AssertProperty(contentString, "endUserIp", "1.1.1.1");
            JsonTests.AssertProperty(contentString, "personalNumber", "201801012392");
            JsonTests.AssertPropertyIsEmptyObject(contentString, "requirement");
            JsonTests.AssertProperty(contentString, "userVisibleData", "dXNlclZpc2libGVEYXRh");
            JsonTests.AssertOnlyProperties(contentString, new[]
            {
                "endUserIp",
                "personalNumber",
                "requirement",
                "userVisibleData"
            });
        }