public void ErrBadClient() { IsReadOnlyTest = true; vClientId = "999"; OauthException e = TestUtil.Throws <OauthException>(() => ExecuteOperation()); CheckException(e, LoginErrors.unauthorized_client, LoginErrorDescs.BadClient); }
public void AuthCodeErrBadClientSecret() { IsReadOnlyTest = true; SetAuthCodeValues(); vSecret = "fail"; OauthException e = TestUtil.Throws <OauthException>(() => ExecuteOperation()); CheckException(e, AccessErrors.invalid_client, AccessErrorDescs.BadClientSecret); }
public void AuthCodeErrBadCode() { IsReadOnlyTest = true; SetAuthCodeValues(); vCode = "999"; OauthException e = TestUtil.Throws <OauthException>(() => ExecuteOperation()); CheckException(e, AccessErrors.invalid_grant, AccessErrorDescs.BadCode); }
public void RefreshErrBadRefresh() { IsReadOnlyTest = true; SetRefreshValues(); vRefresh = "999"; OauthException e = TestUtil.Throws <OauthException>(() => ExecuteOperation()); CheckException(e, AccessErrors.invalid_request, AccessErrorDescs.BadRefresh); }
/*--------------------------------------------------------------------------------------------*/ 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"); }
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."); }
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."); }
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."); }
/*--------------------------------------------------------------------------------------------*/ 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."); }
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."); }
/*--------------------------------------------------------------------------------------------*/ 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."); }
/*--------------------------------------------------------------------------------------------*/ 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."); }