Ejemplo n.º 1
0
        public void TestRateLimitInitalization()
        {
            var settings = VariousFunctions.LoadTestSettings();

            // Create a new Client Authentication based off of the ClientId
            var clientAuthentication = new ClientAuthentication(settings.ClientId, true);

            // Validate rate limit data is correct
            Assert.IsTrue(clientAuthentication.RateLimit.ClientLimit > 0);
            Assert.IsTrue(clientAuthentication.RateLimit.UserLimit > 0);
        }
Ejemplo n.º 2
0
        public async Task TestCodeAuth()
        {
            var settings = VariousFunctions.LoadTestSettings();

            // Create a new OAuth2 Authentication
            var oAuth2Authentication = new OAuth2Authentication(settings.ClientId, settings.ClientSecret, false);
            var authorizationUrl     = oAuth2Authentication.CreateAuthorizationUrl(OAuth2Type.Code, "dicks");
            var code = "1234";

            try
            {
                await oAuth2Authentication.AuthorizeWithCode(code);
            }
            catch (ImgurResponseFailedException exception)
            {
                Assert.AreEqual(exception.ImgurResponse.Data.ErrorDescription, "Refresh token doesn't exist or is invalid for the client");
            }
        }
Ejemplo n.º 3
0
        public async Task TestPinAuth()
        {
            var settings = VariousFunctions.LoadTestSettings();

            // Create a new OAuth2 Authentication
            var oAuth2Authentication = new OAuth2Authentication(settings.ClientId, settings.ClientSecret, false);
            var authorizationUrl     = oAuth2Authentication.CreateAuthorizationUrl(OAuth2Type.Pin, "dicks");

            Assert.AreNotEqual("", authorizationUrl);
            var pin = "1234";

            try
            {
                await oAuth2Authentication.AuthorizeWithPin(pin);
            }
            catch (ImgurResponseFailedException exception)
            {
                Assert.AreEqual(exception.ImgurResponse.Data.ErrorDescription, "Invalid Pin");
            }
        }