public void CredentialsPrompt_ShowDialog_ShowSaveCheckBox() { var prompt = new CredentialsPrompt { ShowSaveCheckBox = true }; prompt.ShowDialog(IntPtr.Zero); }
public void CredentialsPrompt_ShowDialog_With_Username() { var prompt = new CredentialsPrompt { Username = "******" }; Assert.Equal(DialogResult.OK, prompt.ShowDialog()); }
public void CredentialsPrompt_ShowDialog_GenericCredentials() { var prompt = new CredentialsPrompt { Title = "Please provide credentials", GenericCredentials = true }; prompt.ShowDialog(IntPtr.Zero); }
private void btnOK_Click(object sender, EventArgs e) { double ExcludeFileSize = double.PositiveInfinity; try { btnOK.Enabled = false; tbSrcFolder.Text = Utility.StripTrailingSlash(tbSrcFolder.Text); tbBackupFolder.Text = Utility.StripTrailingSlash(tbBackupFolder.Text); // If specifying a root folder, then we actually need the trailing slash due to some quarks in Windows. It also looks nice. if (tbSrcFolder.Text.Length == 2 && tbSrcFolder.Text[1] == ':') { tbSrcFolder.Text = tbSrcFolder.Text + "\\"; } if (tbBackupFolder.Text.Length == 2 && tbBackupFolder.Text[1] == ':') { tbBackupFolder.Text = tbBackupFolder.Text + "\\"; } string CompleteBackupFolder; for (; ;) { try { Path.GetFullPath(tbBackupFolder.Text); } catch (Exception) { MessageBox.Show("Please provide a valid backup folder path."); return; } CompleteBackupFolder = tbBackupFolder.Text + "\\" + tbProjectName.Text; try { if (tbProjectName.Text.Contains("\\")) { throw new Exception(); } Path.GetFullPath(CompleteBackupFolder); } catch (Exception) { MessageBox.Show("Please ensure that the project name is a valid filename. It cannot include any of the following characters: \\ / : * ? \" < > |"); return; } try { using (NetworkConnection newconn = new NetworkConnection(tbSrcFolder.Text, m_Project.SourceCredentials)) { NativeDirectoryInfo.CheckAccessToDirectory(tbSrcFolder.Text); } } catch (DirectoryNotFoundException) { if (MessageBox.Show("The source folder does not exist or is offline. ZippyBackup cannot verify access to the folder at this time.", "Warning", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) { return; } } catch (System.Security.Authentication.InvalidCredentialException) { MessageBox.Show("The credentials provided do not have access to the source folder. Please use the Security tab to provide proper credentials."); return; } catch (System.IO.IOException ex) { MessageBox.Show(ex.Message); return; } try { using (NetworkConnection newself = new NetworkConnection(tbBackupFolder.Text, m_Project.BackupCredentials)) { NativeDirectoryInfo.CheckAccessToDirectory(tbBackupFolder.Text); } } catch (DirectoryNotFoundException) { if (MessageBox.Show("The backup folder does not exist. Would you like to create it?", "Question", MessageBoxButtons.YesNo) == DialogResult.No) { return; } Directory.CreateDirectory(tbBackupFolder.Text); } catch (System.Security.Authentication.InvalidCredentialException) { MessageBox.Show("The credentials provided do not have access to the backup folder. Please use the Security tab to provide proper credentials."); return; } catch (System.IO.IOException ex) { MessageBox.Show(ex.Message); return; } #if false if (cbUseVSS.Checked) { if (m_Project.BackupCredentials.Provided) { MessageBox.Show("Cannot support credentials for the backup user (besides the user launching ZippyBackup) and also for Volume Shadow Service access (administrator)."); return; } if (!m_Project.SourceCredentials.Provided) { NetworkCredential Credential = CredentialsPrompt.PromptForCredentials( CredentialsPrompt.ServerNameFromPath(new DirectoryInfo(tbSrcFolder.Text).Root.Name), "Credentials are required to take a Volume Shadow Service snapshot."); if (Credential == null) { m_Project.SourceCredentials.Clear(); return; } m_Project.SourceCredentials = new StoredNetworkCredentials(Credential); } } #endif break; } # if false if (!Directory.Exists(tbSrcFolder.Text)) { MessageBox.Show("The source folder does not exist! If the folder is offline, please bring it online for the setup process."); return; } if (!Directory.Exists(tbBackupFolder.Text)) { if (MessageBox.Show("The backup folder does not exist. Would you like to create it?", "Question", MessageBoxButtons.YesNo) == DialogResult.No) { return; } Directory.CreateDirectory(tbBackupFolder.Text); } # endif if (Utility.IsContainedIn(tbSrcFolder.Text, tbBackupFolder.Text))
public void CredentialsPrompt_ShowDialog_ShouldNotThrowError() { var prompt = new CredentialsPrompt(); prompt.ShowDialog(); }
public void CredentialsPrompt_Create_ShouldNotBeNull() { var credentialsPrompt = new CredentialsPrompt(); Assert.NotNull(credentialsPrompt); }
public void CredentialsPrompt_ShowDialog_WithParent_ShouldNotThrowError() { var prompt = new CredentialsPrompt(); prompt.ShowDialog(IntPtr.Zero); }
/// <summary> /// Prompts the user for the login/pass necessary (WNDR routers need it) /// </summary> /// <returns>Whether the user clicked OK</returns> public override bool PromptCredentials() { CredentialsPrompt credDlg = new CredentialsPrompt(); credDlg.ShowDialog(); if (credDlg.DialogResult == true) { _loginCredentials = new NetworkCredential(credDlg.userName, credDlg.password); Settings.Default.savedCreds = CrappyCrypt.Encrypt(String.Format("{0}|{1}", credDlg.userName, credDlg.password)); Settings.Default.Save(); } return (credDlg.DialogResult == true); }