Ejemplo n.º 1
0
        public void List()
        {
            var util = new FtpUtilities();

            util.List("ftp://nic.funet.fi");//открытый ftp
            //с чем сравнивать?
        }
Ejemplo n.º 2
0
        public void UploadNotExists()
        {
            string uploadFileName = "solution-upload";
            string uploadUrl      = "ftp://localhost/unit-tests/solutionTests/upload";

            var exeName = uploadFileName + "-not-exist";
            var config  = Configuration.Load(FileSystem, uploadUrl, "");

            var folder       = string.Format("{0}/{1}/{2}", config.Site, FtpUtilities.GetLocalIP4(), exeName);
            var fileName     = string.Format("{0}.txt", uploadFileName);
            var fullFileName = string.Format("{0}/{1}", folder, fileName);

            if (FileSystem.Exists(FileSystem.Combine(folder, fileName)))
            {
                FileSystem.DeleteFile(fullFileName);
                FileSystem.DeleteFolder(folder);
            }

            var unit = new Solution
            {
                LocalSourcePath = uploadFileName + ".txt",
                Task            = new Task
                {
                    ExecutableName = exeName,
                },
                Configuration = config,
            };

            unit.Upload();

            Assert.IsTrue(FileSystem.Exists(FileSystem.Combine(folder, fileName)));
        }
Ejemplo n.º 3
0
        public void Combine2()
        {
            var    util = new FtpUtilities();
            String path = "ftp://folder/";
            String file = "file";

            Assert.AreEqual("ftp://folder/file", util.Combine(path, file));
        }
Ejemplo n.º 4
0
        public void Download_ftp()
        {
            var        util = new FtpUtilities();
            FileStream FS   = File.Create("README.txt");

            util.Download("ftp://www.nic.funet.fi/pub/unix/OpenBSD/README", FS);
            FS.Close();
        }//http://www.nic.funet.fi/pub/unix/OpenBSD/README
Ejemplo n.º 5
0
        public void GetInfoPath()
        {
            var site     = "";
            var expected = string.Format("{1}\\info.json", site, FtpUtilities.GetLocalIP4());


            var unit = Configuration.Load(new LocalFileSystem(), site, "");

            Assert.AreEqual(expected, unit.InfoPath);
        }
Ejemplo n.º 6
0
        public void Exists_With_Slash()
        {
            FileSystem.CreateFolder("folder");
            FileStream ST = File.Create("SolutionTests.txt");

            ST.Close();
            var util = new FtpUtilities();

            util.Exists("ftp://www.nic.funet.fi/pub/unix/OpenBSD/");
            //Authority
        }
Ejemplo n.º 7
0
        public void CreateVirtualDirectory()
        {
            string name = Guid.NewGuid().ToString("N");

            string testDir = Path.Combine(Path.GetTempPath(), name);

            Directory.CreateDirectory(testDir);

            string username  = Uhuru.Utilities.Credentials.GenerateCredential(5);
            string groupname = Uhuru.Utilities.Credentials.GenerateCredential(5);
            string password  = "******";

            string decoratedUsername = Uhuru.Utilities.WindowsVCAPUsers.CreateDecoratedUser(username, password);

            WindowsUsersAndGroups.CreateGroup(groupname, "Delete me. Uhuru test.");


            int port = Uhuru.Utilities.NetworkInterface.GrabEphemeralPort();

            FtpUtilities.CreateFtpSite(name, testDir, port);

            Assert.IsFalse(FtpUtilities.HasUserAccess(name, decoratedUsername));
            Assert.IsFalse(FtpUtilities.HasGroupAccess(name, groupname));

            FtpUtilities.AddUserAccess(name, decoratedUsername);
            FtpUtilities.AddGroupAccess(name, groupname);

            Assert.IsTrue(FtpUtilities.HasUserAccess(name, decoratedUsername));
            Assert.IsTrue(FtpUtilities.HasGroupAccess(name, groupname));

            FtpUtilities.DeleteUserAccess(name, decoratedUsername);
            FtpUtilities.DeleteGroupAccess(name, groupname);

            Assert.IsTrue(FtpUtilities.Exists(name));
            Assert.IsTrue(FtpUtilities.GetFtpSties().Contains(name));
            Assert.IsFalse(FtpUtilities.HasUserAccess(name, decoratedUsername));
            Assert.IsFalse(FtpUtilities.HasGroupAccess(name, groupname));


            FtpUtilities.DeleteFtpSite(name);

            Assert.IsFalse(FtpUtilities.Exists(name));
            Assert.IsFalse(FtpUtilities.GetFtpSties().Contains(name));

            WindowsUsersAndGroups.DeleteGroup(groupname);
            Uhuru.Utilities.WindowsVCAPUsers.DeleteDecoratedBasedUser(username);
        }
Ejemplo n.º 8
0
        public void Exists_Current_Dir()
        {
            var util = new FtpUtilities();

            util.Exists("/");
        }
Ejemplo n.º 9
0
        public void GetFolferName_backslash()
        {
            var util = new FtpUtilities();

            Assert.AreEqual("ftp://foldername", util.GetFolderName("ftp://foldername\\filename"));
        }
Ejemplo n.º 10
0
        public void GetFolferName_with_ftp()
        {
            var util = new FtpUtilities();

            Assert.AreEqual("ftp://foldername", util.GetFolderName("ftp://foldername/filename"));
        }
Ejemplo n.º 11
0
        public void GetFileName2()
        {
            var util = new FtpUtilities();

            Assert.AreEqual("filename", util.GetFileName("folder/filename"));
        }
Ejemplo n.º 12
0
        public void GetFileName_Null()
        {
            var util = new FtpUtilities();

            Assert.AreEqual(null, util.GetFileName(null));
        }
Ejemplo n.º 13
0
        public void GetFileName_Empty()
        {
            var util = new FtpUtilities();

            Assert.AreEqual("", util.GetFileName(""));
        }
Ejemplo n.º 14
0
        public void GetFileName()
        {
            var util = new FtpUtilities();

            Assert.AreEqual("file.txt", util.GetFileName("file.txt"));
        }
Ejemplo n.º 15
0
        public void Combine_ftp()
        {
            var util = new FtpUtilities();

            Assert.AreEqual("ftp://www.nic.funet.fi/pub/unix/openbsd/readme", util.Combine("ftp://www.nic.funet.fi/pub/unix/OpenBSD", "README"));
        }
Ejemplo n.º 16
0
        public void GetIP()
        {
            var addr = FtpUtilities.GetLocalIP4();

            Assert.AreEqual(AddressFamily.InterNetwork, addr.AddressFamily);
        }