コード例 #1
0
        public void Bitlogin_FailedLogout_ClientSendingFakeSignature()
        {
            BitloginServer bitloginServer = new BitloginServer(Random.value);
            BitloginClient bitloginClient = new BitloginClient();

            HiMessage hiMessage = bitloginClient.GetHiMessage();
            BitloginProtocolMessage okSignThisMessage = bitloginServer.GetOkSignThisMessage(hiMessage);
            VerifyMeMessage         verifyMeMessage   = bitloginClient.GetVerifyMeMessage(okSignThisMessage as OkSignThisMessage);

            bitloginServer.GetAuthenticationResult(verifyMeMessage);

            Account.VerificationState currentClientVerificationStateInServer = bitloginServer.GetVerificationStateOfAccount(bitloginClient.LegacyAddress);
            Assert.IsTrue(currentClientVerificationStateInServer == Account.VerificationState.verified);

            LogOutRequestMessage logOutRequestMessage = bitloginClient.GetLogOutRequestMessage();

            logOutRequestMessage.signature = bitloginClient.SignMessage("Wrong message to sign");

            BitloginProtocolMessage logOutResponse = bitloginServer.LogOutRequest(logOutRequestMessage);

            Assert.IsInstanceOf <ErrorMessage>(logOutResponse);
            Assert.IsTrue(((ErrorMessage)logOutResponse).errorCode == 400);

            Account.VerificationState currentClientVerificationStateInServerAfterLogOut = bitloginServer.GetVerificationStateOfAccount(bitloginClient.LegacyAddress);
            Assert.IsTrue(currentClientVerificationStateInServerAfterLogOut == Account.VerificationState.verified);
        }
コード例 #2
0
        public void Bitlogin_FailedLogout_ClientWasNeverLoggedIn()
        {
            BitloginServer bitloginServer = new BitloginServer(Random.value);
            BitloginClient bitloginClient = new BitloginClient();

            Account.VerificationState currentClientVerificationStateInServer = bitloginServer.GetVerificationStateOfAccount(bitloginClient.LegacyAddress);
            Assert.IsTrue(currentClientVerificationStateInServer == Account.VerificationState.unknown);

            LogOutRequestMessage    logOutRequestMessage = bitloginClient.GetLogOutRequestMessage();
            BitloginProtocolMessage logOutResponse       = bitloginServer.LogOutRequest(logOutRequestMessage);

            Assert.IsInstanceOf <ErrorMessage>(logOutResponse);
            Assert.IsTrue(((ErrorMessage)logOutResponse).errorCode == 600);

            Account.VerificationState currentClientVerificationStateInServerAfterLogOut = bitloginServer.GetVerificationStateOfAccount(bitloginClient.LegacyAddress);
            Assert.IsTrue(currentClientVerificationStateInServerAfterLogOut == Account.VerificationState.unknown);
        }
コード例 #3
0
        public void Bitlogin_SuccessLoginAndLogout()
        {
            BitloginClient bitloginClient = new BitloginClient();
            BitloginServer bitloginServer = new BitloginServer(Random.value);

            HiMessage hiMessage = bitloginClient.GetHiMessage();
            BitloginProtocolMessage okSignThisMessage = bitloginServer.GetOkSignThisMessage(hiMessage);
            VerifyMeMessage         verifyMeMessage   = bitloginClient.GetVerifyMeMessage(okSignThisMessage as OkSignThisMessage);

            bitloginServer.GetAuthenticationResult(verifyMeMessage);

            Account.VerificationState currentClientVerificationStateInServer = bitloginServer.GetVerificationStateOfAccount(bitloginClient.LegacyAddress);
            Assert.IsTrue(currentClientVerificationStateInServer == Account.VerificationState.verified);

            LogOutRequestMessage    logOutRequestMessage = bitloginClient.GetLogOutRequestMessage();
            BitloginProtocolMessage logoutResult         = bitloginServer.LogOutRequest(logOutRequestMessage);

            Assert.IsInstanceOf <LogOutSuccessMessage>(logoutResult);
            Account.VerificationState currentClientVerificationStateInServerAfterLogOut = bitloginServer.GetVerificationStateOfAccount(bitloginClient.LegacyAddress);
            Assert.IsTrue(currentClientVerificationStateInServerAfterLogOut == Account.VerificationState.unknown);
        }