NIFI-2797: - Correcting download URIs for OTPs.

This closes #1038.

Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
Matt Gilman 2016-09-20 12:50:55 -04:00 committed by Bryan Bende
parent 684f417406
commit e10b4beb90
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
2 changed files with 8 additions and 8 deletions

View File

@ -31,11 +31,11 @@ public class OtpAuthenticationFilter extends NiFiAuthenticationFilter {
private static final Logger logger = LoggerFactory.getLogger(OtpAuthenticationFilter.class); private static final Logger logger = LoggerFactory.getLogger(OtpAuthenticationFilter.class);
private static final Pattern PROVENANCE_DOWNLOAD_PATTERN = private static final Pattern PROVENANCE_DOWNLOAD_PATTERN =
Pattern.compile("/controller/provenance/events/[0-9]+/content/(?:(?:output)|(?:input))"); Pattern.compile("/provenance-events/([0-9]+)/content/((?:input)|(?:output))");
private static final Pattern QUEUE_DOWNLOAD_PATTERN = private static final Pattern QUEUE_DOWNLOAD_PATTERN =
Pattern.compile("/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/connections/[a-f0-9\\-]{36}/flowfiles/[a-f0-9\\-]{36}/content"); Pattern.compile("/flowfile-queues/([a-f0-9\\-]{36})/flowfiles/([a-f0-9\\-]{36})/content");
private static final Pattern TEMPLATE_DOWNLOAD_PATTERN = private static final Pattern TEMPLATE_DOWNLOAD_PATTERN =
Pattern.compile("/controller/templates/[a-f0-9\\-]{36}"); Pattern.compile("/templates/[a-f0-9\\-]{36}/download");
protected static final String ACCESS_TOKEN = "access_token"; protected static final String ACCESS_TOKEN = "access_token";

View File

@ -65,7 +65,7 @@ public class OtpAuthenticationFilterTest {
when(request.isSecure()).thenReturn(true); when(request.isSecure()).thenReturn(true);
when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn("my-access-token"); when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn("my-access-token");
when(request.getContextPath()).thenReturn("/nifi-api"); when(request.getContextPath()).thenReturn("/nifi-api");
when(request.getPathInfo()).thenReturn("/controller/config"); when(request.getPathInfo()).thenReturn("/flow/cluster/summary");
assertNull(otpAuthenticationFilter.attemptAuthentication(request)); assertNull(otpAuthenticationFilter.attemptAuthentication(request));
} }
@ -88,7 +88,7 @@ public class OtpAuthenticationFilterTest {
when(request.isSecure()).thenReturn(true); when(request.isSecure()).thenReturn(true);
when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN); when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN);
when(request.getContextPath()).thenReturn("/nifi-api"); when(request.getContextPath()).thenReturn("/nifi-api");
when(request.getPathInfo()).thenReturn("/controller/provenance/events/0/content/input"); when(request.getPathInfo()).thenReturn("/provenance-events/0/content/input");
final OtpAuthenticationRequestToken result = (OtpAuthenticationRequestToken) otpAuthenticationFilter.attemptAuthentication(request); final OtpAuthenticationRequestToken result = (OtpAuthenticationRequestToken) otpAuthenticationFilter.attemptAuthentication(request);
assertEquals(DOWNLOAD_TOKEN, result.getToken()); assertEquals(DOWNLOAD_TOKEN, result.getToken());
@ -101,7 +101,7 @@ public class OtpAuthenticationFilterTest {
when(request.isSecure()).thenReturn(true); when(request.isSecure()).thenReturn(true);
when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN); when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN);
when(request.getContextPath()).thenReturn("/nifi-api"); when(request.getContextPath()).thenReturn("/nifi-api");
when(request.getPathInfo()).thenReturn("/controller/provenance/events/0/content/output"); when(request.getPathInfo()).thenReturn("/provenance-events/0/content/output");
final OtpAuthenticationRequestToken result = (OtpAuthenticationRequestToken) otpAuthenticationFilter.attemptAuthentication(request); final OtpAuthenticationRequestToken result = (OtpAuthenticationRequestToken) otpAuthenticationFilter.attemptAuthentication(request);
assertEquals(DOWNLOAD_TOKEN, result.getToken()); assertEquals(DOWNLOAD_TOKEN, result.getToken());
@ -116,7 +116,7 @@ public class OtpAuthenticationFilterTest {
when(request.isSecure()).thenReturn(true); when(request.isSecure()).thenReturn(true);
when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN); when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN);
when(request.getContextPath()).thenReturn("/nifi-api"); when(request.getContextPath()).thenReturn("/nifi-api");
when(request.getPathInfo()).thenReturn(String.format("/controller/process-groups/root/connections/%s/flowfiles/%s/content", uuid, uuid)); when(request.getPathInfo()).thenReturn(String.format("/flowfile-queues/%s/flowfiles/%s/content", uuid, uuid));
final OtpAuthenticationRequestToken result = (OtpAuthenticationRequestToken) otpAuthenticationFilter.attemptAuthentication(request); final OtpAuthenticationRequestToken result = (OtpAuthenticationRequestToken) otpAuthenticationFilter.attemptAuthentication(request);
assertEquals(DOWNLOAD_TOKEN, result.getToken()); assertEquals(DOWNLOAD_TOKEN, result.getToken());
@ -131,7 +131,7 @@ public class OtpAuthenticationFilterTest {
when(request.isSecure()).thenReturn(true); when(request.isSecure()).thenReturn(true);
when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN); when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN);
when(request.getContextPath()).thenReturn("/nifi-api"); when(request.getContextPath()).thenReturn("/nifi-api");
when(request.getPathInfo()).thenReturn(String.format("/controller/templates/%s", uuid)); when(request.getPathInfo()).thenReturn(String.format("/templates/%s/download", uuid));
final OtpAuthenticationRequestToken result = (OtpAuthenticationRequestToken) otpAuthenticationFilter.attemptAuthentication(request); final OtpAuthenticationRequestToken result = (OtpAuthenticationRequestToken) otpAuthenticationFilter.attemptAuthentication(request);
assertEquals(DOWNLOAD_TOKEN, result.getToken()); assertEquals(DOWNLOAD_TOKEN, result.getToken());