public void When_CallApi_alerts_Is_Called_ApiResponseList_Is_Returned() { var response = zap.CallApi("core", "view", "alerts", null); ApiResponseList apiResponseList = (ApiResponseList)response; Assert.IsInstanceOfType(response, typeof(ApiResponseList)); }
/** * Returns list of config parameters of authentication credentials for a given context id. * Each item in the list is a map with keys "name" and "mandatory". * * @param contextId Id of a context. * @return List of authentication credentials configuration parameters. * @throws ProxyException */ public List <Dictionary <String, String> > getAuthenticationCredentialsConfigParams(String contextId) { ApiResponseList apiResponseList = (ApiResponseList)clientApi.users .getAuthenticationCredentialsConfigParams(contextId); return(getConfigParams(apiResponseList)); }
public int getScanProgress(int id) { ApiResponseList response = (ApiResponseList)clientApi.ascan.scans(); ApiResponseSet scanResponse = (ApiResponseSet)response.List.First(s => ((ApiResponseSet)s).Dictionary["id"].Equals(id.ToString())); return(Int32.Parse(scanResponse.Dictionary["progress"])); }
public ApiResponseList GetAllEmployees() { string api = $"{urlApi}/GetAllEMployees"; var request = (HttpWebRequest)WebRequest.Create(api); request.Method = "GET"; request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"; request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; var response = (HttpWebResponse)request.GetResponse(); string content = string.Empty; using (var stream = response.GetResponseStream()) { using (var sr = new StreamReader(stream)) { content = sr.ReadToEnd(); } } string result = string.Empty; JavaScriptSerializer js = new JavaScriptSerializer(); ApiResponseList con = js.Deserialize <ApiResponseList>(content); return(con); }
public ScanResponse(ApiResponseList responseList) { foreach (IApiResponse rawResponse in responseList.List) { scans.Add(new ScanInfo((ApiResponseSet)rawResponse)); } scans.Sort(); }
/** * Returns the list of authentication config parameters. * Each config parameter is a map with keys "name" and "mandatory", holding the values name of the configuration parameter and whether it is mandatory/optional respectively. * * @param authMethod Valid authentication method name. * @return List of configuration parameters for the given authentication method name. * @throws ProxyException */ public List <Dictionary <String, String> > getAuthMethodConfigParameters(String authMethod) { ApiResponseList apiResponseList = null; apiResponseList = (ApiResponseList)clientApi.authentication .getAuthenticationMethodConfigParams(authMethod); return(getConfigParams(apiResponseList)); }
/** * Returns the list of scripting engines that ZAP supports. * * @return List of script engines. * @throws ProxyException */ public List <String> listEngines() { List <String> engines = new List <String>(); ApiResponseList apiResponseList = (ApiResponseList)clientApi.script.listEngines(); foreach (IApiResponse apiResponse in apiResponseList.List) { engines.Add(((ApiResponseElement)apiResponse).Value); } return(engines); }
public List <String> getSpiderResults(int id) { List <String> results = new List <string>(); ApiResponseList responseList = (ApiResponseList)clientApi.spider .results(id.ToString()); foreach (IApiResponse response in responseList.List) { results.Add(((ApiResponseElement)response).Value); } return(results); }
/** * Returns the supported authentication methods by ZAP. * * @return list of supported authentication methods. * @throws ProxyException */ public List <String> getSupportedAuthenticationMethods() { ApiResponseList apiResponseList = null; apiResponseList = (ApiResponseList)clientApi.authentication .getSupportedAuthenticationMethods(); List <String> supportedAuthenticationMethods = new List <String>(); foreach (IApiResponse apiResponse in apiResponseList.List) { supportedAuthenticationMethods.Add(((ApiResponseElement)apiResponse).Value); } return(supportedAuthenticationMethods); }
/** * Returns the list of scripts loaded into ZAP. * * @return List of scripts. * @throws ProxyException */ public List <Script> listScripts() { ApiResponseList apiResponseList = (ApiResponseList)clientApi.script.listScripts(); List <Script> scripts = new List <Script>(); if (apiResponseList != null) { foreach (IApiResponse apiResponse in apiResponseList.List) { scripts.Add(new Script((ApiResponseSet)apiResponse)); } } return(scripts); }
public void When_CallApi_getSupportedAuthenticationMethods_Is_Called_ApiResponseList_With_formBasedAuthentication_IsReturned() { var response = zap.CallApi("authentication", "view", "getSupportedAuthenticationMethods", null); bool formBasedAuthenticationFound = false; ApiResponseList apiResponseList = (ApiResponseList)response; foreach (var item in apiResponseList.List) { var apiResponseElement = (ApiResponseElement)item; if (apiResponseElement.Value == "formBasedAuthentication") { formBasedAuthenticationFound = true; break; } } Assert.IsTrue(formBasedAuthenticationFound); }
public ApiResponseList GetAllEMployees() { ApiResponseList response = new ApiResponseList(); try { var result = employee.GetEmployees(); response.Data = result; response.Message = "OK"; response.Success = true; } catch (Exception ex) { response.Message = $"Error: {ex.Message}"; response.Success = false; } return(response); }
private List <Dictionary <String, String> > getConfigParams(ApiResponseList apiResponseList) { List <Dictionary <String, String> > fields = new List <Dictionary <String, String> >( apiResponseList.List.Count); foreach (ApiResponseSet apiResponseSet in apiResponseList.List) { Dictionary <String, String> field = new Dictionary <String, String>(); // attributes field in apiResponseSet is not initialized with the keys from the map. So, there is no way to dynamically obtain the keys beside looking for "name" and "mandatory". // List<String> attributes = Arrays.asList(apiResponseSet.getAttributes()); // for (String attribute : attributes) { // field.put(attribute, apiResponseSet.getAttribute(attribute)); // } field.Add("name", apiResponseSet.Dictionary["name"]); field.Add("mandatory", apiResponseSet.Dictionary["mandatory"]); fields.Add(field); } return(fields); }
public int getSpiderProgress(int id) { ApiResponseList response = (ApiResponseList)clientApi.spider.scans(); return(new ScanResponse(response).getScanById(id).Progress); }
public int getLastScannerScanId() { ApiResponseList response = (ApiResponseList)clientApi.ascan.scans(); return((new ScanResponse(response)).getLastScan().Id); }