Esempio n. 1
0
        public void TestGenerateCode()
        {
            var mock      = new SteamWebMock();
            var guardMock = new SteamGuardAccountMock();

            guardMock.WithArgs("GenerateSteamGuardCode")(TestSteamGuardCode);

            this.linker.LinkedAccount = guardMock;

            this.linker.FinalizeAddAuthenticator(mock, TestSmsCode, response =>
            {
                Assert.AreEqual(AuthenticatorLinker.FinalizeResult.GeneralFailure, response);
            });
        }
Esempio n. 2
0
        public void TestErrorCodes()
        {
            var mock = new SteamWebMock();

            mock.WithArgs("MobileLoginRequest", ApiEndpoints.STEAMAPI_BASE + "/ITwoFactorService/FinalizeAddAuthenticator/v0001", "POST", this.checkFinalize)(new object[] { "{response: {server_time: 0, status: 89, want_more: false, success: false}}", HttpStatusCode.OK });

            var guardMock = new SteamGuardAccountMock();

            guardMock.WithArgs("GenerateSteamGuardCode")(TestSteamGuardCode);

            this.linker.LinkedAccount = guardMock;

            this.linker.FinalizeAddAuthenticator(mock, TestSmsCode, response =>
            {
                Assert.AreEqual(AuthenticatorLinker.FinalizeResult.BadSMSCode, response);
            });

            mock = new SteamWebMock();
            mock.WithArgs("MobileLoginRequest", ApiEndpoints.STEAMAPI_BASE + "/ITwoFactorService/FinalizeAddAuthenticator/v0001", "POST", this.checkFinalize)(new object[] { "{response: {server_time: 0, status: 0, want_more: true, success: false}}", HttpStatusCode.OK });

            this.linker.FinalizeAddAuthenticator(mock, TestSmsCode, response =>
            {
                Assert.AreEqual(AuthenticatorLinker.FinalizeResult.GeneralFailure, response);
            });

            mock = new SteamWebMock();
            mock.WithArgs("MobileLoginRequest", ApiEndpoints.STEAMAPI_BASE + "/ITwoFactorService/FinalizeAddAuthenticator/v0001", "POST", this.checkFinalize)(new object[] { "{response: {server_time: 0, status: 88, want_more: true, success: false}}", HttpStatusCode.OK });

            this.linker.FinalizeAddAuthenticator(mock, TestSmsCode, response =>
            {
                Assert.AreEqual(AuthenticatorLinker.FinalizeResult.GeneralFailure, response);
            });

            mock = new SteamWebMock();
            mock.WithArgs("MobileLoginRequest", ApiEndpoints.STEAMAPI_BASE + "/ITwoFactorService/FinalizeAddAuthenticator/v0001", "POST", this.checkFinalize)(new object[] { "{response: {server_time: 0, status: 0, want_more: true, success: true}}", HttpStatusCode.OK });

            this.linker.FinalizeAddAuthenticator(mock, TestSmsCode, response =>
            {
                Assert.AreEqual(AuthenticatorLinker.FinalizeResult.GeneralFailure, response);
            });

            mock = new SteamWebMock();
            mock.WithArgs("MobileLoginRequest", ApiEndpoints.STEAMAPI_BASE + "/ITwoFactorService/FinalizeAddAuthenticator/v0001", "POST", this.checkFinalize)(new object[] { "{response: {server_time: 0, status: 88, want_more: true, success: true}}", HttpStatusCode.OK });

            this.linker.FinalizeAddAuthenticator(mock, TestSmsCode, response =>
            {
                Assert.AreEqual(AuthenticatorLinker.FinalizeResult.UnableToGenerateCorrectCodes, response);
            });
        }
Esempio n. 3
0
        public void TestLinkAuth()
        {
            var mock = new SteamWebMock();

            mock.WithArgs("MobileLoginRequest", ApiEndpoints.STEAMAPI_BASE + "/ITwoFactorService/FinalizeAddAuthenticator/v0001", "POST", this.checkFinalize)(new object[] { "{response: {server_time: 0, status: 1, want_more: false, success: true}}", HttpStatusCode.OK });

            var guardMock = new SteamGuardAccountMock();

            guardMock.WithArgs("GenerateSteamGuardCode")(TestSteamGuardCode);

            this.linker.LinkedAccount = guardMock;

            this.linker.FinalizeAddAuthenticator(mock, TestSmsCode, response =>
            {
                Assert.AreEqual(AuthenticatorLinker.FinalizeResult.Success, response);
            });

            Assert.IsTrue(this.linker.LinkedAccount.FullyEnrolled);
        }