protected override async Task <bool> TrySetJobPasswords(Job job)
        {
            var smtpAccount = job.Accounts.GetSmtpAccount(job.Profile);

            if (smtpAccount == null) //The account must be checked, since it is executed before the Action.Check...
            {
                var message = new MessageInteraction(Translation.NoAccount, Translation.SendTestMail, MessageOptions.OK, MessageIcon.Error);
                InteractionRequest.Raise(message);
                return(false);
            }

            job.Passwords.SmtpPassword = smtpAccount.Password;

            if (!string.IsNullOrWhiteSpace(job.Passwords.SmtpPassword))
            {
                return(true);
            }

            var recipientsString = GetRecipientsString(job.Profile.EmailSmtpSettings);
            var title            = Translation.SetSmtpServerPassword;
            var description      = Translation.SmtpServerPasswordLabel;
            var interaction      = new PasswordOverlayInteraction(PasswordMiddleButton.None, title, description, false);

            interaction.IntroText = recipientsString;

            await InteractionRequest.RaiseAsync(interaction);

            if (interaction.Result != PasswordResult.StorePassword)
            {
                return(false);
            }

            job.Passwords.SmtpPassword = interaction.Password;
            return(true);
        }
Ejemplo n.º 2
0
        public void DuringPasswordInteraction_ShowsRecipientsWithReplacedTokens()
        {
            var recipientToWithToken  = "<username>@to.local";
            var recipientCcWithToken  = "<username>@cc.local";
            var recipientBccWithToken = "<username>@bcc.local";
            var expectedUserName      = Environment.UserName;

            _profile.EmailSmtpSettings.Recipients    = recipientToWithToken;
            _profile.EmailSmtpSettings.RecipientsCc  = recipientCcWithToken;
            _profile.EmailSmtpSettings.RecipientsBcc = recipientBccWithToken;
            _tokenReplacer.AddStringToken("username", expectedUserName);
            //_interactionRequest.RegisterInteractionHandler<PasswordOverlayInteraction>(interaction => interaction.Result = PasswordResult.Cancel);
            PasswordOverlayInteraction interaction = null;

            _interactionInvoker.Invoke(Arg.Do <PasswordOverlayInteraction>(i =>
            {
                interaction = i;
                i.Result    = PasswordResult.Cancel;
            }));

            var assistant = BuildAssistant();

            assistant.SendTestMail(_profile, _accounts);

            StringAssert.Contains(recipientToWithToken.Replace("<username>", expectedUserName), interaction.IntroText);
            StringAssert.Contains(recipientCcWithToken.Replace("<username>", expectedUserName), interaction.IntroText);
            StringAssert.Contains(recipientBccWithToken.Replace("<username>", expectedUserName), interaction.IntroText);
        }
        public void CanSkip_WithSkipEnabled_IsTrue()
        {
            var viewModel   = CreateViewModel();
            var interaction = new PasswordOverlayInteraction(PasswordMiddleButton.Skip, "", "");
            var helper      = new InteractionHelper <PasswordOverlayInteraction>(viewModel, interaction);

            Assert.IsTrue(viewModel.CanSkip);
        }
        public void PasswordOverlayTranslation_FormatInvalidPasswordMessage_SetsTextWithActionName()
        {
            var viewModel   = CreateViewModel();
            var pwOVtr      = new PasswordOverlayTranslation();
            var interaction = new PasswordOverlayInteraction(PasswordMiddleButton.Remove, "", pwOVtr.FormatInvalidPasswordMessage("ActionName"), false);
            var sometext    = "Invalid password for 'ActionName'";

            Assert.AreEqual(sometext, interaction.PasswordDescription);
        }
        public void OkCommand_OnExecute_CompletesInteraction()
        {
            var viewModel   = CreateViewModel();
            var interaction = new PasswordOverlayInteraction(PasswordMiddleButton.Skip, "", "");
            var helper      = new InteractionHelper <PasswordOverlayInteraction>(viewModel, interaction);

            viewModel.OkCommand.Execute(null);

            Assert.AreEqual(PasswordResult.StorePassword, interaction.Result);
            Assert.IsTrue(helper.InteractionIsFinished);
        }
        public void CancelCommand_OnExecute_FinishesInteraction()
        {
            var viewModel   = CreateViewModel();
            var interaction = new PasswordOverlayInteraction(PasswordMiddleButton.Remove, "", "");
            var helper      = new InteractionHelper <PasswordOverlayInteraction>(viewModel, interaction);

            viewModel.Password = "******";

            viewModel.CancelCommand.Execute(null);

            Assert.AreEqual(PasswordResult.Cancel, interaction.Result);
            Assert.AreEqual("", interaction.Password);
            Assert.IsTrue(helper.InteractionIsFinished);
        }
        public void FtpPassword_OnSet_WritesToInteractionAndCallCanExecuteChanged()
        {
            var interacton = new PasswordOverlayInteraction(PasswordMiddleButton.Skip, "", "");
            var viewModel  = CreateViewModel();

            viewModel.SetInteraction(interacton);

            var canExecuteChanged = false;

            viewModel.OkCommand.CanExecuteChanged += (sender, args) => canExecuteChanged = true;

            viewModel.Password = "******";

            Assert.AreEqual("MyPassword", interacton.Password);
            Assert.IsTrue(canExecuteChanged);
        }
Ejemplo n.º 8
0
        private void RaisePasswordOverlayInteraction(JobLoginFailedEventArgs args, ManualResetEventSlim interactionFinishedEvent)
        {
            var invalidPasswordMessage = _passwordOverlayTranslation.FormatInvalidPasswordMessage(args.ActionDisplayName);
            var interaction            = new PasswordOverlayInteraction(PasswordMiddleButton.None, _passwordOverlayTranslation.ReenterPassword, invalidPasswordMessage, false);

            _interactionRequest.Raise(interaction, delegate(PasswordOverlayInteraction overlayInteraction)
            {
                if (overlayInteraction.Result == PasswordResult.StorePassword)
                {
                    args.ContinueAction(interaction.Password);
                }
                else
                {
                    args.AbortAction();
                }
                interactionFinishedEvent.Set();
            });
        }
        public void OnInteractionSet_SetsPasswordsInView()
        {
            var viewModel         = CreateViewModel();
            var canExecuteChanged = false;

            viewModel.OkCommand.CanExecuteChanged += (sender, args) => canExecuteChanged = true;
            var interaction = new PasswordOverlayInteraction(PasswordMiddleButton.Skip, "", "")
            {
                Password = "******"
            };

            var actionWasCalled = false;

            viewModel.SetPasswordAction = x => actionWasCalled = true;

            viewModel.SetInteraction(interaction);
            Assert.IsTrue(actionWasCalled);
            Assert.IsTrue(canExecuteChanged);
        }
Ejemplo n.º 10
0
        private bool TrySetJobPasswords(Job job, ConversionProfile profile)
        {
            var smtpAccount = job.Accounts.GetSmtpAccount(profile);

            if (smtpAccount == null)
            {
                var message = new MessageInteraction(_translation.NoAccount, "PDFCreator", MessageOptions.OK, MessageIcon.Error);
                _interactionRequest.Raise(message);
                return(false);
            }

            job.Passwords.SmtpPassword = smtpAccount.Password;

            if (!string.IsNullOrWhiteSpace(job.Passwords.SmtpPassword))
            {
                return(true);
            }

            var sb = new StringBuilder();

            sb.AppendLine(_translation.RecipientsLabel);
            sb.AppendLine(profile.EmailSmtpSettings.Recipients);

            var title       = _translation.SetSmtpServerPassword;
            var description = _translation.SmtpServerPasswordLabel;

            var interaction = new PasswordOverlayInteraction(PasswordMiddleButton.None, title, description, false);

            interaction.IntroText = sb.ToString();

            // TODO: Can this be done with IInteractionRequest? (it's hard to wait for the response!)
            _interactionInvoker.Invoke(interaction);

            if (interaction.Result != PasswordResult.StorePassword)
            {
                return(false);
            }

            job.Passwords.SmtpPassword = interaction.Password;
            return(true);
        }
Ejemplo n.º 11
0
        private bool TrySetJobPasswords(Job job, ConversionProfile profile)
        {
            var smtpAccount = job.Accounts.GetSmtpAccount(profile);

            if (smtpAccount == null)
            {
                var message = new MessageInteraction(_translation.NoAccount, "PDFCreator", MessageOptions.OK, MessageIcon.Error);
                _interactionRequest.Raise(message);
                return(false);
            }

            job.Passwords.SmtpPassword = smtpAccount.Password;

            if (!string.IsNullOrWhiteSpace(job.Passwords.SmtpPassword))
            {
                return(true);
            }

            var recipientsString = GetRecipientsString(job.Profile.EmailSmtpSettings, job.TokenReplacer);

            var title       = _translation.SetSmtpServerPassword;
            var description = _translation.SmtpServerPasswordLabel;

            var interaction = new PasswordOverlayInteraction(PasswordMiddleButton.None, title, description, false);

            interaction.IntroText = recipientsString;

            // TODO:Use IInteractionRequest
            _interactionInvoker.Invoke(interaction);

            if (interaction.Result != PasswordResult.StorePassword)
            {
                return(false);
            }

            job.Passwords.SmtpPassword = interaction.Password;
            return(true);
        }