Esempio n. 1
0
        public void TestPublishFilesImpersonateNoMachineName()
        {
            WNetCancelConnection2(TestSharePrivate, 0, true);
            using (var app = new VisualStudioApp()) {
                try {
                    var    project = app.OpenProject(@"TestData\HelloWorld.sln");
                    string subDir  = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");

                    app.OpenSolutionExplorer().SelectProject(project);

                    using (var creds = CredentialsDialog.PublishSelection(app)) {
                        creds.UserName = PrivateShareUserWithoutMachine;
                        creds.Password = PrivateSharePassword;
                        creds.OK();
                    }

                    System.Threading.Thread.Sleep(2000);

                    using (var helper = new NetUseHelper()) {
                        string dir   = Path.Combine(helper.Drive + "\\", subDir);
                        var    files = WaitForFiles(dir);
                        Assert.AreEqual(1, files.Length);
                        Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                        Directory.Delete(dir, true);
                    }
                } finally {
                    WNetCancelConnection2(TestSharePrivate, 0, true);
                }
            }
        }
Esempio n. 2
0
        public void TestPublishFilesImpersonate(VisualStudioApp app)
        {
            WNetCancelConnection2(TestSharePrivate, 0, true);
            try {
                var    project = app.OpenProject(@"TestData\HelloWorld.sln");
                string subDir  = Guid.NewGuid().ToString();
                project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir);
                app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");

                app.OpenSolutionExplorer().SelectProject(project);

                using (var creds = CredentialsDialog.PublishSelection(app)) {
                    creds.UserName = PrivateShareUserWithoutMachine;
                    creds.Password = PrivateSharePassword;
                    creds.OK();
                }

                string dir = Path.Combine(TestSharePrivate, subDir);

                var files = WaitForFiles(dir);

                Assert.IsNotNull(files, "Timed out waiting for files to publish");
                Assert.AreEqual(1, files.Length);
                Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                Directory.Delete(dir, true);
            } finally {
                WNetCancelConnection2(TestSharePrivate, 0, true);
            }
        }
Esempio n. 3
0
        public void TestPublishFilesImpersonateCancelCredentials()
        {
            WNetCancelConnection2(TestSharePrivate, 0, true);
            using (var app = new VisualStudioApp()) {
                try {
                    var    project = app.OpenProject(@"TestData\HelloWorld.sln");
                    string subDir  = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                    string dir = Path.Combine(TestSharePrivate, subDir);

                    app.OpenSolutionExplorer().SelectProject(project);

                    using (var creds = CredentialsDialog.PublishSelection(app)) {
                        creds.UserName = PrivateShareUser;
                        creds.Password = PrivateSharePasswordIncorrect;
                        creds.Cancel();
                    }

                    var          statusBar = app.GetService <IVsStatusbar>(typeof(SVsStatusbar));
                    string       text      = null;
                    const string expected  = "Publish failed: Access to the path";

                    for (int i = 0; i < 10; i++)
                    {
                        ErrorHandler.ThrowOnFailure(statusBar.GetText(out text));

                        if (text.StartsWith(expected))
                        {
                            break;
                        }
                        System.Threading.Thread.Sleep(1000);
                    }

                    Assert.IsTrue(text.StartsWith(expected), "Expected '{0}', got '{1}'", expected, text);
                } finally {
                    WNetCancelConnection2(TestSharePrivate, 0, true);
                }
            }
        }