Ejemplo n.º 1
0
        public void should_initiate_2fa()
        {
            var response = ShortCode.RequestTwoFactorAuth(new ShortCode.TwoFactorAuthRequest
            {
                to  = Configuration.Instance.Settings["test_number"],
                pin = 1467
            });

            Assert.AreEqual("1", response.message_count);
        }
Ejemplo n.º 2
0
        public void should_initiate_2fa()
        {
            var response = ShortCode.RequestTwoFactorAuth(new ShortCode.TwoFactorAuthRequest
            {
                to  = "17775551212",
                pin = 1467
            });

            Assert.AreEqual("1", response.message_count);
        }
Ejemplo n.º 3
0
        public void should_initiate_2fa()
        {
            var request = new ShortCode.TwoFactorAuthRequest
            {
                to  = "15555551212",
                pin = 1247
            };

            SetExpect($"{RestUrl}/sc/us/2fa/json?to={request.to}&pin={request.pin}&api_key={ApiKey}&api_secret={ApiSecret}&",
                      "{\"message-count\":\"1\",\"messages\":[{\"message-id\":\"02000000AE70FFFF\",\"to\":\"15555551212\",\"remaining-balance\":7.546,\"message-price\":0.0048,\"ok\":true,\"status\":\"0\",\"msisdn\":\"15555551212\",\"network\":\"US-FIXED\",\"messageId\":\"02000000AE70FFFF\",\"remainingBalance\":7.546,\"messagePrice\":0.0048}]}");

            var response = ShortCode.RequestTwoFactorAuth(request);

            Assert.AreEqual("1", response.message_count);
            Assert.AreEqual("15555551212", response.messages.First().to);
        }
Ejemplo n.º 4
0
        public void should_initiate_2fa()
        {
            var resp = new Mock <IWebResponse>();

            resp.Setup(e => e.GetResponseStream()).Returns(new MemoryStream(Encoding.UTF8.GetBytes("{\"message-count\":\"1\",\"messages\":[{\"message-id\":\"02000000AE70FFFF\",\"to\":\"15555551212\",\"remaining-balance\":7.546,\"message-price\":0.0048,\"ok\":true,\"status\":\"0\",\"msisdn\":\"15555551212\",\"network\":\"US-FIXED\",\"messageId\":\"02000000AE70FFFF\",\"remainingBalance\":7.546,\"messagePrice\":0.0048}]}")));
            _request.Setup(e => e.GetResponse()).Returns(resp.Object);
            var request = new ShortCode.TwoFactorAuthRequest
            {
                to  = "15555551212",
                pin = 1247
            };
            var response = ShortCode.RequestTwoFactorAuth(request);

            _mock.Verify(h => h.CreateHttp(new Uri(
                                               string.Format("{0}/sc/us/2fa/json?to={1}&pin={2}&api_key={3}&api_secret={4}&", RestUrl, request.to, request.pin, ApiKey, ApiSecret))),
                         Times.Once);
            Assert.AreEqual("1", response.message_count);
            Assert.AreEqual("15555551212", response.messages.First().to);
        }