public async Task Get_ActionConfigurations() { GetActionConfigurationsResponse response = await actionService.GetActionConfigurationsAsync(VALID_IP, VALID_USER, VALID_PASS); if (response.IsSuccess) { foreach (ActionConfiguration ac in response.Configurations) { Console.WriteLine(ac.ToString()); } } Assert.IsTrue(response.IsSuccess && response.HttpStatusCode == System.Net.HttpStatusCode.OK && !response.SOAPContent.IsEmpty); }
/// <summary> /// Method to retrieve the existing Action Rules on a device /// </summary> /// <param name="IP">The device ip address</param> /// <param name="User">User to authenticate the http request</param> /// <param name="Password">Password to use</param> /// <returns>GetActionRulesResponse, GetActionRulesResponse.ActionRules contains a List<ActionRule> with the stored ActionRules of the device</returns> public async Task <GetActionRulesResponse> GetActionRulesAsync(string IP, string User, string Password) { GetActionConfigurationsResponse configResponse = await this.GetActionConfigurationsAsync(IP, User, Password); GetActionRulesResponse rulesResponse = parseGetActionRulesResponse(await base.sendRequestAsync(IP, User, Password, @"<act:GetActionRules/>")); if (configResponse.IsSuccess && rulesResponse.IsSuccess) { foreach (ActionRule r in rulesResponse.ActionRules) { r.Configuration = configResponse.Configurations.Where(x => x.ConfigID == r.Configuration.ConfigID).FirstOrDefault(); } } return(rulesResponse); }
private GetActionConfigurationsResponse parseGetActionConfigResponse(ServiceResponse Response) { GetActionConfigurationsResponse response = Response.Factory <GetActionConfigurationsResponse>(); if (Response.IsSuccess) { try { XElement configResponse = Response.SOAPContent.Element(NS_SOAP_ENV + "Body").Element(NS_ACTION + "GetActionConfigurationsResponse").Element(NS_ACTION + "ActionConfigurations"); ActionConfiguration conf; foreach (XElement el in configResponse.Elements()) { conf = new ActionConfiguration(); conf.ConfigID = int.Parse(el.Element(NS_ACTION + "ConfigurationID").Value); conf.Name = el.Element(NS_ACTION + "Name").Value; conf.TemplateToken = el.Element(NS_ACTION + "TemplateToken").Value; foreach (XElement element in el.Element(NS_ACTION + "Parameters").Elements()) { conf.Parameters.Add(element.Attribute("Name").Value, element.Attribute("Value").Value); } response.Configurations.Add(conf); } } catch (Exception ex) { response.IsSuccess = false; response.Content = "[ParseActionConfigResponse] " + ex.Message; } } return(response); }
public async Task Get_ActionConfigurationsWithWrongCredentials_IsUnauthorized() { GetActionConfigurationsResponse response = await actionService.GetActionConfigurationsAsync(VALID_IP, "root2", VALID_PASS); Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.Unauthorized); }