Ejemplo n.º 1
0
        public void ErrBadClient()
        {
            IsReadOnlyTest = true;
            vClientId      = "999";
            OauthException e = TestUtil.Throws <OauthException>(() => ExecuteOperation());

            CheckException(e, LoginErrors.unauthorized_client, LoginErrorDescs.BadClient);
        }
Ejemplo n.º 2
0
        public void AuthCodeErrBadClientSecret()
        {
            IsReadOnlyTest = true;
            SetAuthCodeValues();
            vSecret = "fail";
            OauthException e = TestUtil.Throws <OauthException>(() => ExecuteOperation());

            CheckException(e, AccessErrors.invalid_client, AccessErrorDescs.BadClientSecret);
        }
Ejemplo n.º 3
0
        public void AuthCodeErrBadCode()
        {
            IsReadOnlyTest = true;
            SetAuthCodeValues();
            vCode = "999";
            OauthException e = TestUtil.Throws <OauthException>(() => ExecuteOperation());

            CheckException(e, AccessErrors.invalid_grant, AccessErrorDescs.BadCode);
        }
Ejemplo n.º 4
0
        public void RefreshErrBadRefresh()
        {
            IsReadOnlyTest = true;
            SetRefreshValues();
            vRefresh = "999";
            OauthException e = TestUtil.Throws <OauthException>(() => ExecuteOperation());

            CheckException(e, AccessErrors.invalid_request, AccessErrorDescs.BadRefresh);
        }
Ejemplo n.º 5
0
        /*--------------------------------------------------------------------------------------------*/
        private void AssertFault(TestDelegate pDelegate, LogoutErrors pError, LogoutErrorDescs pDesc)
        {
            OauthException oe = TestUtil.Throws <OauthException>(pDelegate);

            Assert.NotNull(oe.OauthError, "OauthError should filled.");
            Assert.AreEqual(pError + "", oe.OauthError.Error, "Invalid OauthError.Error");
            Assert.AreEqual(OauthLogoutTasks.ErrDescStrings[(int)pDesc] + "",
                            oe.OauthError.ErrorDesc, "Invalid OauthError.ErrorDesc");
        }
Ejemplo n.º 6
0
        public void NewFault()
        {
            OauthException oe = vTasks.NewFault(AccessErrors.invalid_request, AccessErrorDescs.NoCode);

            Assert.NotNull(oe, "Result should not be null.");
            Assert.AreEqual("invalid_request", oe.OauthError.Error, "Incorrect OauthError.Error.");
            Assert.AreEqual(OauthAccessTasks.ErrDescStrings[(int)AccessErrorDescs.NoCode],
                            oe.OauthError.ErrorDesc, "Incorrect OauthError.ErrorDesc.");
        }
Ejemplo n.º 7
0
        public void NewFault()
        {
            OauthException oe = vTasks.NewFault(LoginErrors.invalid_request, LoginErrorDescs.NoClient);

            Assert.NotNull(oe, "Result should not be null.");
            Assert.AreEqual("invalid_request", oe.OauthError.Error, "Incorrect OauthError.Error.");
            Assert.AreEqual(OauthLoginTasks.ErrDescStrings[(int)LoginErrorDescs.NoClient],
                            oe.OauthError.ErrorDesc, "Incorrect OauthError.ErrorDesc.");
        }
Ejemplo n.º 8
0
        public void ErrNoTokenMatch()
        {
            IsReadOnlyTest = true;
            vToken         = "12345678901234567890123456789012";
            OauthException e = TestUtil.Throws <OauthException>(() => ExecuteOperation());

            Assert.AreEqual(LogoutErrors.invalid_request.ToString(), e.OauthError.Error,
                            "Incorrect Error.");
            Assert.AreEqual(OauthLogoutTasks.ErrDescStrings[(int)LogoutErrorDescs.NoTokenMatch],
                            e.OauthError.ErrorDesc, "Incorrect ErrorDesc.");
        }
Ejemplo n.º 9
0
        /*--------------------------------------------------------------------------------------------*/
        private void AssertFault(LoginErrors pError, LoginErrorDescs pDesc)
        {
            var oe = new OauthException(null, null);

            vMockTasks
            .Setup(x => x.NewFault(pError, pDesc))
            .Returns(oe);

            OauthException thrown = TestUtil.Throws <OauthException>(DoExecute);

            Assert.AreEqual(oe, thrown, "Incorrect thrown OauthException.");
        }
Ejemplo n.º 10
0
        public void SuccessScopeDeny()
        {
            const long memId  = (long)SetupMemberId.BookZach;
            const long userId = (long)SetupUserId.Zach;

            OpCtx.Auth.SetCookieUserId(userId);
            vAllowScope = false;

            Member origMem = XOauthLoginGetOperation.GetMember(OpCtx.Data, memId);

            Assert.AreEqual(true, origMem.OauthScopeAllow, "This test requires an allowed scope.");

            OauthException e = TestUtil.Throws <OauthException>(() => ExecuteScope());

            XOauthLoginGetOperation.CheckException(e,
                                                   LoginErrors.access_denied, LoginErrorDescs.AccessDeny);

            Member updatedMem = XOauthLoginGetOperation.GetMember(OpCtx.Data, memId);

            Assert.AreEqual(false, updatedMem.OauthScopeAllow, "Incorrect OauthScopeAllow.");
            Assert.AreNotEqual(origMem.OauthScopeAllow, updatedMem.OauthScopeAllow,
                               "OauthScopeAllow did not change.");
        }
Ejemplo n.º 11
0
 /*--------------------------------------------------------------------------------------------*/
 private void CheckException(OauthException pEx, AccessErrors pErr, AccessErrorDescs pDesc)
 {
     Assert.AreEqual(pErr.ToString(), pEx.OauthError.Error, "Incorrect Error.");
     Assert.AreEqual(OauthAccessTasks.ErrDescStrings[(int)pDesc], pEx.OauthError.ErrorDesc,
                     "Incorrect ErrorDesc.");
 }
Ejemplo n.º 12
0
 /*--------------------------------------------------------------------------------------------*/
 public static void CheckException(OauthException pEx, LoginErrors pErr, LoginErrorDescs pDesc)
 {
     Assert.AreEqual(pErr.ToString(), pEx.OauthError.Error, "Incorrect Error.");
     Assert.AreEqual(OauthLoginTasks.ErrDescStrings[(int)pDesc], pEx.OauthError.ErrorDesc,
                     "Incorrect ErrorDesc.");
 }