@Test public void build_json_for_new_scan_with_basic_auth_contians_basic_login_parts() throws Exception { BasicLoginConfig basicLoginConfig = mock(BasicLoginConfig.class); when(config.getLoginConfig()).thenReturn(basicLoginConfig); when(basicLoginConfig.asBasic()).thenReturn(basicLoginConfig); when(basicLoginConfig.isBasic()).thenReturn(true); when(basicLoginConfig.getLoginURL()).thenReturn(new URL("https: when(basicLoginConfig.getUser()).thenReturn("weblogin-user"); when(basicLoginConfig.getPassword()).thenReturn("weblogin-password"); when(basicLoginConfig.getRealm()).thenReturn("www.example.com"); String json = adapterToTest.buildJsonForCreateNewScan(jsonAdapterSupport, config); String expected= NetsparkerAdapterTestFileSupport.getTestfileSupport().loadTestFile("login/basic_weblogin_expected1.json"); assertEquals(expected, json); }
String buildJsonForCreateNewScan(JSONAdapterSupport jsonAdapterSupport, NetsparkerAdapterConfig config) throws AdapterException { Map<String, Object> map = new TreeMap<>(); map.put(TARGET_URI, config.getTargetAsString()); if (config.hasAgentGroup()) { map.put(AGENT_GROUP_NAME, config.getAgentGroupName()); } else { map.put(AGENT_NAME, config.getAgentName()); } map.put(POLICY_ID, config.getPolicyId()); webLoginSupport.addAuthorizationInfo(config, map); String jsonAsString = jsonAdapterSupport.toJSON(map); return jsonAsString; }
NetsparkerAdapterV1 extends AbstractAdapter<NetsparkerAdapterContext, NetsparkerAdapterConfig> implements NetsparkerAdapter { String buildJsonForCreateNewScan(JSONAdapterSupport jsonAdapterSupport, NetsparkerAdapterConfig config) throws AdapterException { Map<String, Object> map = new TreeMap<>(); map.put(TARGET_URI, config.getTargetAsString()); if (config.hasAgentGroup()) { map.put(AGENT_GROUP_NAME, config.getAgentGroupName()); } else { map.put(AGENT_NAME, config.getAgentName()); } map.put(POLICY_ID, config.getPolicyId()); webLoginSupport.addAuthorizationInfo(config, map); String jsonAsString = jsonAdapterSupport.toJSON(map); return jsonAsString; } }
NetsparkerAdapterV1 extends AbstractAdapter<NetsparkerAdapterContext, NetsparkerAdapterConfig> implements NetsparkerAdapter { String buildJsonForCreateNewScan(JSONAdapterSupport jsonAdapterSupport, NetsparkerAdapterConfig config) throws AdapterException { Map<String, Object> map = new TreeMap<>(); map.put(TARGET_URI, config.getTargetAsString()); if (config.hasAgentGroup()) { map.put(AGENT_GROUP_NAME, config.getAgentGroupName()); } else { map.put(AGENT_NAME, config.getAgentName()); } map.put(POLICY_ID, config.getPolicyId()); webLoginSupport.addAuthorizationInfo(config, map); String jsonAsString = jsonAdapterSupport.toJSON(map); return jsonAsString; }  }
NetsparkerAdapterV1 extends AbstractAdapter<NetsparkerAdapterContext, NetsparkerAdapterConfig> implements NetsparkerAdapter { String buildJsonForCreateNewScan(JSONAdapterSupport jsonAdapterSupport, NetsparkerAdapterConfig config) throws AdapterException { Map<String, Object> map = new TreeMap<>(); map.put(TARGET_URI, config.getTargetAsString()); if (config.hasAgentGroup()) { map.put(AGENT_GROUP_NAME, config.getAgentGroupName()); } else { map.put(AGENT_NAME, config.getAgentName()); } map.put(POLICY_ID, config.getPolicyId()); webLoginSupport.addAuthorizationInfo(config, map); String jsonAsString = jsonAdapterSupport.toJSON(map); return jsonAsString; }  @Override String execute(NetsparkerAdapterConfig config, AdapterRuntimeContext runtimeContext); @Override int getAdapterVersion(); }
NetsparkerAdapterV1 extends AbstractAdapter<NetsparkerAdapterContext, NetsparkerAdapterConfig> implements NetsparkerAdapter { String buildJsonForCreateNewScan(JSONAdapterSupport jsonAdapterSupport, NetsparkerAdapterConfig config) throws AdapterException { Map<String, Object> map = new TreeMap<>(); map.put(TARGET_URI, config.getTargetAsString()); if (config.hasAgentGroup()) { map.put(AGENT_GROUP_NAME, config.getAgentGroupName()); } else { map.put(AGENT_NAME, config.getAgentName()); } map.put(POLICY_ID, config.getPolicyId()); webLoginSupport.addAuthorizationInfo(config, map); String jsonAsString = jsonAdapterSupport.toJSON(map); return jsonAsString; }  @Override String execute(NetsparkerAdapterConfig config, AdapterRuntimeContext runtimeContext); @Override int getAdapterVersion();  }