summaryrefslogtreecommitdiffstats
path: root/docs/submodules/optf
AgeCommit message (Expand)AuthorFilesLines
2020-03-18Update git submodulesvrvarma1-0/+0
2020-03-17Update git submodulesShankaranarayanan Puzhavakath Narayanan1-0/+0
2020-03-17Update git submodulesVikas Varma1-0/+0
2020-03-17Update git submodulesvrvarma1-0/+0
2020-03-17Update git submodulesShankaranarayanan Puzhavakath Narayanan1-0/+0
2020-03-17Update git submodulesvrvarma1-0/+0
2020-03-17Update git submodulesvrvarma1-0/+0
2020-03-16Update git submodulesvrvarma1-0/+0
2020-03-16Update git submodulesShankaranarayanan Puzhavakath Narayanan1-0/+0
2020-03-16Update git submodulesvrvarma1-0/+0
2020-03-16Update git submodulesShankaranarayanan Puzhavakath Narayanan1-0/+0
2020-03-16Update git submodulesShankaranarayanan Puzhavakath Narayanan1-0/+0
2020-03-16Update git submodulesVikas Varma1-0/+0
2020-03-09Update git submodulesShankaranarayanan Puzhavakath Narayanan1-0/+0
2020-03-05Update git submodulesVikas Varma1-0/+0
2020-03-05Update git submodulesVikas Varma1-0/+0
2020-03-05Update git submodulesShankaranarayanan Puzhavakath Narayanan1-0/+0
2020-03-05Update git submodulesvrvarma1-0/+0
2020-03-05Update git submodulesVikas Varma1-0/+0
2020-03-04Update git submodulesvrvarma1-0/+0
2020-03-04Update git submodulesvrvarma1-0/+0
2020-03-04Update git submodulesvrvarma1-0/+0
2020-02-29Update git submoduleskrishnaa961-0/+0
2020-02-28Update git submodulesVikas Varma1-0/+0
2020-02-28Update git submodulesVikas Varma1-0/+0
2020-02-28Update git submodulesShankar Narayanan1-0/+0
2020-02-28Update git submoduleskrishnaa961-0/+0
2020-02-27Update git submodulesvrvarma1-0/+0
2020-02-27Update git submodulesVikas Varma1-0/+0
2020-02-26Update git submodulesvrvarma1-0/+0
2020-02-26Update git submodulesShankaranarayanan Puzhavakath Narayanan1-0/+0
2020-02-26Update git submodulesIkramullah, Ikram1-0/+0
2020-02-26Update git submodules2020-02-20Update git submodulesvrvarma1-0/+0
2020-02-20Update git submodulesdhebeha1-0/+0
2020-02-19Update git submodulesvrvarma1-0/+0
2020-02-12Update git submodulesShankaranarayanan Puzhavakath Narayanan1-0/+0
2020-02-12Update git submodulesVikas Varma1-0/+0
2020-02-12Update git submodulesVikas Varma1-0/+0
2020-02-12Update git submodulesJessica Wagantall1-0/+0
2020-02-12Update git submodulesJerry Flood1-0/+0
2020-02-11Update git submodulesvrvarma1-0/+0
2020-01-29Update git submodulesvrvarma1-0/+0
2020-01-28Update git submodulesIkram Ikramullah1-0/+0
2020-01-24Update git submodulesShankaranarayanan Puzhavakath Narayanan1-0/+0
2020-01-23Update git submodulesIsaac Manuel Raj1-0/+0
2020-01-22Update git submodulesVikas Varma1-0/+0
2020-01-22Update git submodulesVikas Varma1-0/+0
2020-01-22Update git submodulesanushadasari1-0/+0
2020-01-22Update git submodulesanushadasari1-0/+0
source -> { copy(source, apps.toPath().resolve(src.relativize(source))); }); // // Get the parameters file correct. // RestServerParameters rest = testData.toObject(testData.getRestServerParametersMap(port), RestServerParameters.class); RestClientParameters policyApiParameters = testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = testData.toObject(testData.getXacmlapplicationParametersMap(false, apps.getAbsolutePath().toString()), XacmlApplicationParameters.class); XacmlPdpParameterGroup params = new XacmlPdpParameterGroup("XacmlPdpParameters", "XacmlPdpGroup", "xacml", rest, policyApiParameters, topicParameterGroup, xacmlApplicationParameters); final Gson gson = new GsonBuilder().create(); File fileParams = appsFolder.newFile("params.json"); String jsonParams = gson.toJson(params); LOGGER.info("Creating new params: {}", jsonParams); Files.write(fileParams.toPath(), jsonParams.getBytes()); // // Start the service // main = startXacmlPdpService(fileParams); XacmlPdpActivator.getCurrent().enableApi(); // // Make sure it is running // if (!NetworkUtil.isTcpPortOpen("localhost", port, 20, 1000L)) { throw new IllegalStateException("Cannot connect to port " + port); } // // Create a client // client = getNoAuthHttpClient(); } @AfterClass public static void after() throws PolicyXacmlPdpException { stopXacmlPdpService(main); client.shutdown(); } @Test public void testDecision_UnsupportedAction() throws Exception { LOGGER.info("Running test testDecision_UnsupportedAction"); DecisionRequest request = new DecisionRequest(); request.setOnapName("DROOLS"); request.setAction("foo"); Map<String, Object> guard = new HashMap<String, Object>(); guard.put("actor", "foo"); guard.put("recipe", "bar"); guard.put("target", "somevnf"); guard.put("clname", "phoneyloop"); request.setResource(guard); ErrorResponse response = getErrorDecision(request); LOGGER.info("Response {}", response); assertThat(response.getResponseCode()).isEqualTo(Status.BAD_REQUEST); assertThat(response.getErrorMessage()).isEqualToIgnoringCase("No application for action foo"); } @Test public void testDecision_Guard() throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException { LOGGER.info("Running test testDecision_Guard"); DecisionRequest request = new DecisionRequest(); request.setOnapName("DROOLS"); request.setAction("guard"); Map<String, Object> guard = new HashMap<String, Object>(); guard.put("actor", "foo"); guard.put("recipe", "bar"); guard.put("target", "somevnf"); guard.put("clname", "phoneyloop"); request.setResource(guard); DecisionResponse response = getDecision(request); LOGGER.info("Response {}", response); assertThat(response.getStatus()).isEqualTo("Permit"); } @Test public void testDecision_Native() throws IOException { LOGGER.info("Running test testDecision_Native"); String xmlRequestAsString = ResourceUtils.getResourceAsString( "src/test/resources/decisions/decision.native.request.xml"); if (xmlRequestAsString == null) { throw new IOException("failed to read the xml request"); } String jsonRequestAsString = ResourceUtils.getResourceAsString( "src/test/resources/decisions/decision.native.request.json"); if (jsonRequestAsString == null) { throw new IOException("failed to read the json request"); } String responseFromXmlRequest = getNativeDecision(xmlRequestAsString, APPLICATION_XACML_XML); LOGGER.info("Response from xml request {}", responseFromXmlRequest); assertThat(responseFromXmlRequest).contains("NOTAPPLICABLE"); String responseFromJsonRequest = getNativeDecision(jsonRequestAsString, APPLICATION_XACML_JSON); LOGGER.info("Response from json request {}", responseFromJsonRequest); assertThat(responseFromJsonRequest).contains("NOTAPPLICABLE"); } private static Main startXacmlPdpService(File params) throws PolicyXacmlPdpException { final String[] XacmlPdpConfigParameters = {"-c", params.getAbsolutePath()}; return new Main(XacmlPdpConfigParameters); } private static void stopXacmlPdpService(final Main main) throws PolicyXacmlPdpException { main.shutdown(); } private DecisionResponse getDecision(DecisionRequest request) { Entity<DecisionRequest> entityRequest = Entity.entity(request, MediaType.APPLICATION_JSON); Response response = client.post("/decision", entityRequest, Collections.emptyMap()); assertEquals(200, response.getStatus()); return HttpClient.getBody(response, DecisionResponse.class); } private String getNativeDecision(String request, String mediaType) { Entity<String> entityRequest = Entity.entity(request, mediaType); Response response = client.post("/xacml", entityRequest, Collections.emptyMap()); assertEquals(200, response.getStatus()); return HttpClient.getBody(response, String.class); } private ErrorResponse getErrorDecision(DecisionRequest request) { Entity<DecisionRequest> entityRequest = Entity.entity(request, MediaType.APPLICATION_JSON); Response response = client.post("/decision", entityRequest, Collections.emptyMap()); assertEquals(400, response.getStatus()); return HttpClient.getBody(response, ErrorResponse.class); } private static HttpClient getNoAuthHttpClient() throws HttpClientConfigException { return HttpClientFactoryInstance.getClientFactory().build(RestClientParameters.builder() .clientName("testDecisionClient") .useHttps(false).allowSelfSignedCerts(false).hostname("localhost").port(port) .basePath("policy/pdpx/v1") .userName("healthcheck").password("zb!XztG34").managed(true).build()); } private static void copy(Path source, Path dest) { try { LOGGER.info("Copying {} to {}", source, dest); Files.copy(source, dest, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { LOGGER.error("Failed to copy {} to {}", source, dest); } } }