public void TestCheckUpdateWithoutUUID() { // If HKEY_LOCAL_MACHINE\Software\Citrix\XenTools\AutoUpdate Identify == NO // Make a call to the specified URL without including the UUID var xsdict = new Dictionary <string, string>(); var brandingdict = new Dictionary <string, string>(); var regdict = new Dictionary <string, Dictionary <string, string> >(); brandingdict.Add("BRANDING_updaterURL", "http://127.0.0.1/updates.tsv"); brandingdict.Add("BRANDING_userAgent", "UnitTest"); xsdict.Add("/guest_agent_features/Guest_agent_auto_update/licensed", "1"); xsdict.Add("/guest_agent_features/Guest_agent_auto_update/parameters/enabled", "1"); xsdict.Add("/guest_agent_features/Guest_agent_auto_update/parameters/update_url", null); xsdict.Add("/guest_agent_features/Guest_agent_auto_update/parameters/allow-driver-install", "NO"); xsdict.Add("data/xd/present", "0"); xsdict.Add("vm", "/vm/11111111-1111-1111-1111-111111111111"); regdict.Add("HKEY_LOCAL_MACHINE\\Software\\Citrix\\XenTools\\AutoUpdate", new Dictionary <string, string>()); regdict["HKEY_LOCAL_MACHINE\\Software\\Citrix\\XenTools\\AutoUpdate"].Add("Identify", "NO"); Version nv = new Version(6, 6, 0, 1); var au = new AutoUpdate(new MockXenStoreItemFactory(xsdict), new MockBranding(brandingdict), new MockGetReg(regdict)); au.version = nv; MockWebClient wc = new MockWebClient(); au.CheckForUpdates(wc); Assert.AreEqual(wc.setUserAgent, true); Assert.AreEqual(wc.setUserAgentUnitTest, true); Assert.AreEqual(wc.urlhasid, false); }
static int Main(string[] args) { try { bool add = false; bool remove = false; bool check = true; if (!IsElevated()) { System.Diagnostics.Debug.Print("XenUpdater.exe must be run by an elevated administrator account"); return((int)HRESULT.E_ACCESSDENIED); } // check params for config options... foreach (string arg in args) { switch (arg.ToLower()) { case "add": add = true; check = false; break; case "remove": remove = true; check = false; break; case "check": check = true; break; default: throw new ArgumentException(arg); } } if (add && !remove && !check) { using (Tasks tasks = new Tasks()) { tasks.AddTask(); } } if (remove && !add && !check) { using (Tasks tasks = new Tasks()) { tasks.RemoveTask(); } } if (check && !add && !remove) { AutoUpdate auto = new AutoUpdate(); auto.CheckNow(); } return(0); } catch (UnauthorizedAccessException e) { System.Diagnostics.Debug.Print("Exception: " + e.ToString()); return((int)HRESULT.E_ACCESSDENIED); } catch (FormatException e) { System.Diagnostics.Debug.Print("Exception: " + e.ToString()); return((int)HRESULT.E_INVALIDARG); } catch (Exception e) { System.Diagnostics.Debug.Print("Exception: " + e.ToString()); return(-1); // TODO: Return the HRESULT of this exception } }
static int Main(string[] args) { int result = -2; if (SingleApp.IsRunning()) return -3; try { bool add = false; bool remove = false; bool check = true; if (!IsElevated()) { Program.Log("XenUpdater.exe must be run by an elevated administrator account"); return (int)HRESULT.E_ACCESSDENIED; } // check params for config options... foreach (string arg in args) { switch (arg.ToLower()) { case "add": add = true; check = false; break; case "remove": remove = true; check = false; break; case "check": check = true; break; default: throw new ArgumentException(arg); } } if (add && !remove && !check) { using (Tasks tasks = new Tasks()) { tasks.AddTask(); } } if (remove && !add && !check) { using (Tasks tasks = new Tasks()) { tasks.RemoveTask(); } } if (check && !add && !remove) { AutoUpdate auto = new AutoUpdate(); auto.CheckNow(); } result = 0; } catch (UnauthorizedAccessException e) { Program.Log("Exception: " + e.ToString()); result = (int)HRESULT.E_ACCESSDENIED; } catch (FormatException e) { Program.Log("Exception: " + e.ToString()); result = (int)HRESULT.E_INVALIDARG; } catch (Exception e) { Program.Log("Exception: " + e.ToString()); result = -1; // TODO: Return the HRESULT of this exception } return result; }