diff --git a/api-policy-component-service/src/main/java/com/ft/up/apipolicy/filters/CheckPublicationPolicy.java b/api-policy-component-service/src/main/java/com/ft/up/apipolicy/filters/CheckPublicationPolicy.java index 28d2e8e..cf17545 100644 --- a/api-policy-component-service/src/main/java/com/ft/up/apipolicy/filters/CheckPublicationPolicy.java +++ b/api-policy-component-service/src/main/java/com/ft/up/apipolicy/filters/CheckPublicationPolicy.java @@ -24,6 +24,7 @@ public class CheckPublicationPolicy implements ApiFilter { private static final String PUBLICATION = "publication"; private static final String PUBLICATION_PREFIX = "PBLC_READ_"; private static final String PINK_FT = "88fdde6c-2aa4-4f78-af02-9f680097cfd6"; + private static final String THING = "http://www.ft.com/thing/"; private final JsonConverter jsonConverter; public CheckPublicationPolicy(JsonConverter jsonConverter) { @@ -57,7 +58,8 @@ private static Boolean checkAccess(Set policies, List publicatio private static List convertObjectToStringList(Object obj) { if (obj instanceof Collection) { - return new ObjectMapper().convertValue(obj, new TypeReference>() {}); + List p = new ObjectMapper().convertValue(obj, new TypeReference>() {}); + return p.stream().map(var -> var.replaceFirst(THING, "")).collect(Collectors.toList()); } else { return Collections.emptyList(); } diff --git a/api-policy-component-service/src/test/java/com/ft/up/apipolicy/filters/CheckPublicationPolicyTest.java b/api-policy-component-service/src/test/java/com/ft/up/apipolicy/filters/CheckPublicationPolicyTest.java index f118bac..9a735b8 100644 --- a/api-policy-component-service/src/test/java/com/ft/up/apipolicy/filters/CheckPublicationPolicyTest.java +++ b/api-policy-component-service/src/test/java/com/ft/up/apipolicy/filters/CheckPublicationPolicyTest.java @@ -29,7 +29,7 @@ public class CheckPublicationPolicyTest { @Test public void ShouldReturnOK() { String entity = - "{ \"type\":\"http://www.ft.com/ontology/content/Article\", \"bodyXML\": \"something here\",\"publication\":[\"8e6c705e-1132-42a2-8db0-c295e29e8658\",\"88fdde6c-2aa4-4f78-af02-9f680097cfd6\"] }"; + "{ \"type\":\"http://www.ft.com/ontology/content/Article\", \"bodyXML\": \"something here\",\"publication\":[\"http://www.ft.com/thing/8e6c705e-1132-42a2-8db0-c295e29e8658\",\"http://www.ft.com/thing/88fdde6c-2aa4-4f78-af02-9f680097cfd6\"] }"; MutableResponse validResponse = new MutableResponse(new MultivaluedHashMap<>(), entity.getBytes()); validResponse.setStatus(200); @@ -47,7 +47,7 @@ public void ShouldReturnOK() { @Test public void ShouldReturn403() { String entity = - "{ \"type\":\"http://www.ft.com/ontology/content/Article\", \"bodyXML\": \"something here\",\"publication\":[\"88fdde6c-2aa4-4f78-af02-9f680097cfd6\"] }"; + "{ \"type\":\"http://www.ft.com/ontology/content/Article\", \"bodyXML\": \"something here\",\"publication\":[\"http://www.ft.com/thing/88fdde6c-2aa4-4f78-af02-9f680097cfd6\"] }"; MutableResponse validResponse = new MutableResponse(new MultivaluedHashMap<>(), entity.getBytes()); validResponse.setStatus(200); @@ -65,7 +65,7 @@ public void ShouldReturn403() { @Test public void ShouldReturnOkWithNoPublicationReadPolicyFtPink() { String entity = - "{ \"type\":\"http://www.ft.com/ontology/content/Article\", \"bodyXML\": \"something here\",\"publication\":[\"88fdde6c-2aa4-4f78-af02-9f680097cfd6\"] }"; + "{ \"type\":\"http://www.ft.com/ontology/content/Article\", \"bodyXML\": \"something here\",\"publication\":[\"http://www.ft.com/thing/88fdde6c-2aa4-4f78-af02-9f680097cfd6\"] }"; MutableResponse validResponse = new MutableResponse(new MultivaluedHashMap<>(), entity.getBytes()); validResponse.setStatus(200); @@ -81,7 +81,7 @@ public void ShouldReturnOkWithNoPublicationReadPolicyFtPink() { @Test public void ShouldDeniedAccessNoPublicationPolicyNonPinkFt() { String entity = - "{ \"type\":\"http://www.ft.com/ontology/content/Article\", \"bodyXML\": \"something here\",\"publication\":[\"8e6c705e-1132-42a2-8db0-c295e29e8658\"] }"; + "{ \"type\":\"http://www.ft.com/ontology/content/Article\", \"bodyXML\": \"something here\",\"publication\":[\"http://www.ft.com/thing/8e6c705e-1132-42a2-8db0-c295e29e8658\"] }"; MutableResponse validResponse = new MutableResponse(new MultivaluedHashMap<>(), entity.getBytes()); validResponse.setStatus(200);