Example #1
0
		public void Init()
		{
			c = new Client (TestSettings.ownCloudInstanceUrl, TestSettings.ownCloudUser, TestSettings.ownCloudPassword);
			payloadData = System.Text.Encoding.UTF8.GetBytes ("owncloud# NUnit Payload\r\nPlease feel free to delete");
			if (!c.UserExists("sharetest"))
				c.CreateUser ("sharetest", "test");
			if (!c.GroupExists("testgroup"))
				c.CreateGroup ("testgroup");
			if (!c.IsUserInGroup("sharetest", "testgroup"))
				c.AddUserToGroup ("sharetest", "testgroup");
		}
Example #2
0
		public static void Main (string[] args)
		{
			var c = new Client ("http://192.168.2.245/owncloud-devel", "admin", "Bno131083");
			/*Console.Write ("Testing DAV:List ... ");
			var list = c.List ("/");
			Console.WriteLine ("Received " + list.Count + " item(s)");
			foreach (var item in list) {
				if (!item.ContentType.Equals ("dav/directory")) {
					Console.Write ("Testing DAV:Downloading: " + item.Path + "/" + item.Name + " ... ");
					var data = c.Download (item.Path + "/" + item.Name);
					Console.WriteLine (data.Length + " Bytes received");
					BinaryReader reader = new BinaryReader (data);
					data.Position = 0;
					byte[] rdata = reader.ReadBytes ((int)data.Length);
					File.WriteAllBytes (item.Name, rdata);
					if (!c.Exists ("/demo"))
						c.CreateDirectory ("/demo");
					Console.Write ("Testing DAV:Uploading " + item.Name + " to /demo/ ... ");
					var status = c.Upload ("/demo/" + item.Name, new MemoryStream (rdata), item.ContentType);
					if (status)
						Console.WriteLine ("DONE");
					else
						Console.WriteLine ("FAILED");
					Console.Write ("Testing DAV:Deleting " + item.Name + " from /demo/ ... ");
					status = c.Delete ("/demo/" + item.Name);
					if (status)
						Console.WriteLine ("DONE");
					else
						Console.WriteLine ("FAILED");
				} else
					continue;
			}
			Console.Write ("Testing OCS:ListOpenRemoteShare ... ");*/
            //c.CreateUser ("test2", "8cs!38s");
            //var ps = c.ShareWithLink("/demo", Convert.ToInt32(OcsPermission.All), "demo", OcsBoolParam.True);
            //var us = c.ShareWithUser("/demo", "test", Convert.ToInt32(OcsPermission.All), OcsBoolParam.False);
            //var gs = c.ShareWithGroup("/demo", "Test123", Convert.ToInt32(OcsPermission.All));
			/*var result = c.IsShared("/demo") ? "is shared" : "is not shared";
			Console.WriteLine ("/demo " + result + ".");*/
			var result = c.SearchUsers ("test");
		}
Example #3
0
		public void Cleanup()
		{
			#region DAV Test CleanUp
			if (c.Exists(TestSettings.testFileName))
				c.Delete (TestSettings.testFileName);
			if (c.Exists(TestSettings.testDirName))
				c.Delete (TestSettings.testDirName);
			if (c.Exists ("/copy-test")) {
				c.Delete ("/copy-test/file.txt");
				c.Delete ("/copy-test");
			}
			if (c.Exists ("/move-test")) {
				c.Delete ("/move-test/file.txt");
				c.Delete ("/move-test");
			}

			if (c.Exists ("/zip-test")) {
				c.Delete ("/zip-test/file.txt");
				c.Delete ("/zip-test");
			}
			#endregion

			#region OCS Share Test CleanUp
			if (c.Exists ("/share-link-test.txt")) {
				if (c.IsShared ("/share-link-test.txt")) {
					var shares = c.GetShares ("/share-link-test.txt");
					foreach (var share in shares)
						c.DeleteShare (share.ShareId);
				}
				c.Delete ("/share-link-test.txt");
			}

			if (c.Exists ("/share-user-test.txt")) {
				if (c.IsShared ("/share-user-test.txt")) {
					var shares = c.GetShares ("/share-user-test.txt");
					foreach (var share in shares)
						c.DeleteShare (share.ShareId);
				}
				c.Delete ("/share-user-test.txt");
			}

			if (c.Exists ("/share-group-test.txt")) {
				if (c.IsShared ("/share-group-test.txt")) {
					var shares = c.GetShares ("/share-group-test.txt");
					foreach (var share in shares)
						c.DeleteShare (share.ShareId);
				}
				c.Delete ("/share-group-test.txt");
			}

			if (c.Exists ("/share-update-test.txt")) {
				if (c.IsShared ("/share-update-test.txt")) {
					var shares = c.GetShares ("/share-update-test.txt");
					foreach (var share in shares)
						c.DeleteShare (share.ShareId);
				}
				c.Delete ("/share-update-test.txt");
			}

			if (c.Exists ("/share-delete-test.txt")) {
				if (c.IsShared ("/share-delete-test.txt")) {
					var shares = c.GetShares ("/share-delete-test.txt");
					foreach (var share in shares)
						c.DeleteShare (share.ShareId);
				}
				c.Delete ("/share-delete-test.txt");
			}

			if (c.Exists ("/share-shared-test.txt")) {
				if (c.IsShared ("/share-shared-test.txt")) {
					var shares = c.GetShares ("/share-shared-test.txt");
					foreach (var share in shares)
						c.DeleteShare (share.ShareId);
				}
				c.Delete ("/share-shared-test.txt");
			}

			if (c.Exists ("/share-get-test.txt")) {
				if (c.IsShared ("/share-get-test.txt")) {
					var shares = c.GetShares ("/share-get-test.txt");
					foreach (var share in shares)
						c.DeleteShare (share.ShareId);
				}
				c.Delete ("/share-get-test.txt");
			}
			#endregion

			#region OCS User Test cleanup
			if (c.UserExists("octestusr1")) {
				var c1 = new Client(TestSettings.ownCloudInstanceUrl, "octestusr1", "test");
				var shares = c1.GetShares("");
				foreach (var share in shares)
					c1.DeleteShare(share.ShareId);
				c.DeleteUser("octestusr1");
			}
			if (c.UserExists("octestusr")) {
				var c2 = new Client(TestSettings.ownCloudInstanceUrl, "octestusr", "test");
				var shares = c2.GetShares("");
				foreach (var share in shares)
					c2.DeleteShare(share.ShareId);
				c.DeleteUser("octestusr");
			}
			#endregion

			#region OCS App Attribute Test Cleanup
			if (c.GetAttribute("files", "test").Count > 0)
				c.DeleteAttribute ("files", "test");
			#endregion

			#region General CleanUp
			var c3 = new Client(TestSettings.ownCloudInstanceUrl, "sharetest", "test");
			var c3shares = c3.GetShares("");
			foreach (var share in c3shares)
				c3.DeleteShare(share.ShareId);
			c.RemoveUserFromGroup ("sharetest", "testgroup");
			c.DeleteGroup ("testgroup");
			c.DeleteUser ("sharetest");
			#endregion
		}