예제 #1
0
        public async Task SignAsync_WithRequirements__ShouldPostJsonPayload_WithRequirements()
        {
            // Arrange

            // Act
            await _bankIdApiClient.SignAsync(new SignRequest("1.1.1.1", "userVisibleData", Encoding.UTF8.GetBytes("userNonVisibleData"), "201801012392", new Requirement(new List <string> {
                "req1", "req2"
            }, true, true)));

            // 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.AssertSubProperty(contentString, "requirement", "allowFingerprint", true);
            JsonTests.AssertSubProperty(contentString, "requirement", "certificatePolicies", new List <string> {
                "req1", "req2"
            });
            JsonTests.AssertSubProperty(contentString, "requirement", "tokenStartRequired", true);
            JsonTests.AssertProperty(contentString, "userVisibleData", "dXNlclZpc2libGVEYXRh");
            JsonTests.AssertProperty(contentString, "userNonVisibleData", "dXNlck5vblZpc2libGVEYXRh");
            JsonTests.AssertOnlyProperties(contentString, new[]
            {
                "endUserIp",
                "personalNumber",
                "requirement",
                "userVisibleData",
                "userNonVisibleData"
            });
        }
예제 #2
0
        public async Task AuthAsync_WithRequirements__ShouldPostJsonPayload_WithRequirements()
        {
            // Arrange

            // Act
            await _bankIdApiClient.AuthAsync(new AuthRequest("1.1.1.1", "201801012392", new Requirement(new List <string> {
                "req1", "req2"
            }, true, true)));

            // 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.AssertSubProperty(contentString, "requirement", "allowFingerprint", true);
            JsonTests.AssertSubProperty(contentString, "requirement", "certificatePolicies", new List <string> {
                "req1", "req2"
            });
            JsonTests.AssertSubProperty(contentString, "requirement", "tokenStartRequired", true);
        }