示例#1
0
        public void GetAuthorizeUri_WithImplicitGrantAuthorizationFlow_ReturnsTokenAsResponseType()
        {
            var uri = OAuthHelper.GetAuthorizeUri(
                OAuthAuthorizationFlow.ImplicitGrant,
                "acme",
                "Client123",
                new Uri("https://myapp.com/oauth"));
            const string ExpectedUrl = "https://acme.egnyte.com/puboauth/token?client_id=Client123&redirect_uri=https://myapp.com/oauth&response_type=token";

            Assert.AreEqual(ExpectedUrl, uri.ToString());
        }
示例#2
0
        public void GetAuthorizeUri_WithMinimumParametersSpecified_ReturnsCorrectUri()
        {
            var uri = OAuthHelper.GetAuthorizeUri(
                OAuthAuthorizationFlow.Code,
                "acme",
                "Client123",
                new Uri("https://myapp.com/oauth"),
                "MyOwnSecret");
            const string ExpectedUrl = "https://acme.egnyte.com/puboauth/token?client_id=Client123&redirect_uri=https://myapp.com/oauth&response_type=code";

            Assert.AreEqual(ExpectedUrl, uri.ToString());
        }
示例#3
0
        public void GetAuthorizeUri_ThrowsArgumentNullException_WhenRedirectUriIsEmpty()
        {
            var exception = Assert.Throws <ArgumentNullException>(
                () => OAuthHelper.GetAuthorizeUri(
                    OAuthAuthorizationFlow.Code,
                    "domain",
                    "id",
                    null,
                    "secret"));

            Assert.IsTrue(exception.Message.Contains("redirectUri"));
        }
示例#4
0
        public void GetAuthorizeUri_ThrowsArgumentNullException_WhenClientIdIsEmpty()
        {
            var exception = Assert.Throws <ArgumentNullException>(
                () => OAuthHelper.GetAuthorizeUri(
                    OAuthAuthorizationFlow.Code,
                    "domain",
                    null,
                    new Uri("https://myapp.com"),
                    "secret"));

            Assert.IsTrue(exception.Message.Contains("clientId"));
        }
示例#5
0
        public void GetAuthorizeUri_ReturnsCorrectUri()
        {
            var uri = OAuthHelper.GetAuthorizeUri(
                OAuthAuthorizationFlow.Code,
                "acme",
                "Client123",
                new Uri("https://myapp.com/oauth"),
                "MyOwnSecret",
                "Egnyte.filesystem",
                "apidemo123",
                true);
            const string ExpectedUrl = "https://acme.egnyte.com/puboauth/token?client_id=Client123&redirect_uri=https://myapp.com/oauth&response_type=code&scope=Egnyte.filesystem&state=apidemo123&mobile=1";

            Assert.AreEqual(ExpectedUrl, uri.ToString());
        }