Beispiel #1
0
        public void TestCreateBasicAirWatchUser()
        {
            // Add basic user
            /*
            AirWatchUser newUser = new AirWatchUser();
            newUser.Email = "*****@*****.**";
            newUser.FirstName = "Vincent";
            newUser.LastName = "Curry";
            newUser.LocationGroupID = locationGroupID;
            newUser.MessageType = "Email";
            newUser.Password = "******";
            newUser.SecurityType = 2;
            newUser.Status = true;
            newUser.UserName = "******";
            newUser.EmailUserName = "******";
            */

            // Add Directory user
            AirWatchUser newUser = new AirWatchUser();
            newUser.UserName = "******";
            newUser.Status = true;
            newUser.SecurityType = 1;
            string userJSON = JsonConvert.SerializeObject(newUser);

            string awSiteURL = awServer;
            RestHandler restHandler = new RestHandler(awSiteURL);
            IRestResponse returnCode = restHandler.RestPostEndpointBasicAuth("/API/v1/system/users/adduser", userName, password, headers, userJSON);
            if (returnCode.StatusDescription == "OK")
            {
                JObject returnedContent = JObject.Parse(returnCode.Content);
                string createdUserId = (string)returnedContent["Value"];
                using (StreamWriter sw = new StreamWriter(createUserFile))
                {
                    sw.WriteLine(Convert.ToString(createdUserId));
                }
            }
            Assert.AreEqual("OK", returnCode.StatusDescription);
        }
Beispiel #2
0
        public void TestRegisterDevice()
        {
            string createdUserID = string.Empty;
            if (File.Exists(createUserFile))
            {
                using (StreamReader sr = new StreamReader(createUserFile))
                {
                    createdUserID = sr.ReadLine();
                }
            }
            else
                Assert.Fail("Not Created User File");

            AirWatchDevices deviceToRegister = new AirWatchDevices();
            // deviceToRegister.AssetNumber = "Asset #1";
            deviceToRegister.FriendlyName = "Scot's Device";
            deviceToRegister.LocationGroupId = locationGroupID;
            deviceToRegister.MessageType = "Email";
            deviceToRegister.ModelId = 2;
            // deviceToRegister.OperatingSystemId = 2;
            deviceToRegister.Ownership = "Corporate";
            deviceToRegister.PlatformId = 2;
            // deviceToRegister.SerialNumber = "DLXNV3RZFLMJ";
            // deviceToRegister.ToEmailAddress = "*****@*****.**";
            // deviceToRegister.Udid = "7BBE62B953C21847AA447919304027C98CCB148C";

            string jsonToSend = JsonConvert.SerializeObject(deviceToRegister);

            string awSiteURL = awServer;
            RestHandler restHandler = new RestHandler(awSiteURL);
            string endpoint = "system/users/" + Convert.ToString(createdUserID) + "/registerdevice";
            IRestResponse returnCode = restHandler.RestPostEndpointBasicAuth(endpoint, userName, password, headers, jsonToSend);
            if (returnCode.StatusDescription == "OK")
                createdUserID = "debug";

            Assert.AreEqual(returnCode.StatusDescription, "OK");
        }