public void OpenVault_throws_on_canceled_oob()
        {
            var flow = new RestFlow()
                       .Post(KeyIterationCount.ToString())
                       .Post(OobRequiredResponse);

            Exceptions.AssertThrowsCanceledMultiFactor(
                () => Client.OpenVault(Username, Password, ClientInfo, CancelingUi, flow),
                "Out of band step is canceled by the user");
        }
        public void OpenVault_throws_on_invalid_password()
        {
            var flow = new RestFlow()
                       .Post(KeyIterationCount.ToString())
                       .Post("<response><error cause='unknownpassword' /></response>");

            Exceptions.AssertThrowsBadCredentials(
                () => Client.OpenVault(Username, Password, ClientInfo, null, flow),
                "Invalid password");
        }
        public void OpenVault_throws_on_failed_otp()
        {
            var flow = new RestFlow()
                       .Post(KeyIterationCount.ToString())
                       .Post(OtpRequiredResponse)
                       .Post("<response><error cause='googleauthfailed' /></response>");

            Exceptions.AssertThrowsBadMultiFactor(
                () => Client.OpenVault(Username, Password, ClientInfo, OtpProvidingUi, flow),
                "Second factor code is incorrect");
        }
        public void OpenVault_returns_accounts()
        {
            var flow = new RestFlow()
                       .Post(KeyIterationCount.ToString())
                       .ExpectUrl("/iterations.php")
                       .Post(OkResponseNoPrivateKey)
                       .ExpectUrl("/login.php")
                       .Get(TestData.BlobBase64)
                       .ExpectUrl("/getaccts.php?")
                       .Post("")
                       .ExpectUrl("/logout.php");

            // TODO: Decryption fails here because of the incorrect password
            var accounts = Client.OpenVault(Username, Password, ClientInfo, null, flow);

            Assert.NotEmpty(accounts);
        }