public async Task ChangePassword() { var newService = YouMailTestService.NewService; var ymPasswordChange = new YouMailPasswordChange { CurrentPassword = newService.Password, NewPassword = "******" }; var ymPasswordRestore = new YouMailPasswordChange { CurrentPassword = ymPasswordChange.NewPassword, NewPassword = ymPasswordChange.CurrentPassword }; await newService.ChangePasswordAsync(ymPasswordChange); // Verify that we can login with the new password var verifyService = new YouMailService(newService.Username, ymPasswordChange.NewPassword, null, YouMailTestService.UserAgent, YouMailTestService.ResponseFormat); var userInfo = await verifyService.GetUserInfoAsync(); // Restore the password await verifyService.ChangePasswordAsync(ymPasswordRestore); }
public async Task Login_Fail() { var service = new YouMailService("0000", "0000", null, YouMailTestService.UserAgent); try { await service.LoginAsync(); Assert.Fail("The login should not have succeeded"); } catch (YouMailException ye) { Assert.IsTrue(ye.StatusCode == HttpStatusCode.Forbidden, "Wrong StatusCode back"); Assert.IsFalse(service.IsLoggedIn); } }
public async Task CreateAccount() { string user = "******"; string password = "******"; var youmail = YouMailTestService.PrivateService; if (await youmail.AccountExistsAsync(user)) { try { var newService = new YouMailService(user, password, null, YouMailTestService.UserAgent); await newService.DeleteAccountAsync(); } catch (YouMailException) { Assert.Fail("Failed to delete old existing account"); } } await youmail.CreateAccountAsync(user, password, "Test", "Account", string.Format(_defaultEmail, user)); { // Reset the service in case we already had logged in with old credentials var newService = new YouMailService(user, password, null, YouMailTestService.UserAgent); await newService.DeleteAccountAsync(); // This should fail the second time bool failed = false; try { await newService.DeleteAccountAsync(); } catch (YouMailException e) { // Either the account doesn't exist, or the user isn't authenticated anymore if (e.StatusCode == HttpStatusCode.NotFound || e.StatusCode == HttpStatusCode.Forbidden) { failed = true; } } Assert.IsTrue(failed); } }
private static async Task VerifySmsCountAsync(TranscriptionSettings settings, YouMailService service) { var oldCount = settings.SmsCount; int newCount = 0; if (oldCount == 0) { newCount = 3; } await service.SetTranscriptionSettingAsync(YMST.c_smsCount, newCount.ToString()); await Task.Delay(delay); var newSettings = await service.GetTranscriptionSettingsAsync(); Assert.AreEqual(newCount, newSettings.SmsCount); await service.SetTranscriptionSettingAsync(YMST.c_smsCount, oldCount.ToString()); await Task.Delay(delay); var oldSettings = await service.GetTranscriptionSettingsAsync(); Assert.AreEqual(oldCount, oldSettings.SmsCount); }
private static void ResetService() { _service = new YouMailService(TestUser, TestPassword, _testAuth, UserAgent, _responseFormat); _service.AuthenticationChanged += OnTestServiceAuthenticationChanged; }