NIFI-2797: - Correcting download URIs for OTPs.

This closes #1038.

Signed-off-by: Bryan Bende <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/3feb59d6
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/3feb59d6
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/3feb59d6

Branch: refs/heads/support/nifi-1.0.x
Commit: 3feb59d690ad1d2f301c8572d09b262299bd23a5
Parents: bde1c24
Author: Matt Gilman <[email protected]>
Authored: Tue Sep 20 12:50:55 2016 -0400
Committer: jpercivall <[email protected]>
Committed: Wed Dec 14 16:20:39 2016 -0500

----------------------------------------------------------------------
 .../nifi/web/security/otp/OtpAuthenticationFilter.java    |  6 +++---
 .../web/security/otp/OtpAuthenticationFilterTest.java     | 10 +++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/3feb59d6/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/main/java/org/apache/nifi/web/security/otp/OtpAuthenticationFilter.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/main/java/org/apache/nifi/web/security/otp/OtpAuthenticationFilter.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/main/java/org/apache/nifi/web/security/otp/OtpAuthenticationFilter.java
index 1ab0b41..34883fc 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/main/java/org/apache/nifi/web/security/otp/OtpAuthenticationFilter.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/main/java/org/apache/nifi/web/security/otp/OtpAuthenticationFilter.java
@@ -31,11 +31,11 @@ public class OtpAuthenticationFilter extends 
NiFiAuthenticationFilter {
     private static final Logger logger = 
LoggerFactory.getLogger(OtpAuthenticationFilter.class);
 
     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 =
-        
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 =
-        Pattern.compile("/controller/templates/[a-f0-9\\-]{36}");
+        Pattern.compile("/templates/[a-f0-9\\-]{36}/download");
 
     protected static final String ACCESS_TOKEN = "access_token";
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/3feb59d6/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/otp/OtpAuthenticationFilterTest.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/otp/OtpAuthenticationFilterTest.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/otp/OtpAuthenticationFilterTest.java
index 791ca54..8027b8f 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/otp/OtpAuthenticationFilterTest.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/otp/OtpAuthenticationFilterTest.java
@@ -65,7 +65,7 @@ public class OtpAuthenticationFilterTest {
         when(request.isSecure()).thenReturn(true);
         
when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn("my-access-token");
         when(request.getContextPath()).thenReturn("/nifi-api");
-        when(request.getPathInfo()).thenReturn("/controller/config");
+        when(request.getPathInfo()).thenReturn("/flow/cluster/summary");
 
         assertNull(otpAuthenticationFilter.attemptAuthentication(request));
     }
@@ -88,7 +88,7 @@ public class OtpAuthenticationFilterTest {
         when(request.isSecure()).thenReturn(true);
         
when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN);
         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);
         assertEquals(DOWNLOAD_TOKEN, result.getToken());
@@ -101,7 +101,7 @@ public class OtpAuthenticationFilterTest {
         when(request.isSecure()).thenReturn(true);
         
when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN);
         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);
         assertEquals(DOWNLOAD_TOKEN, result.getToken());
@@ -116,7 +116,7 @@ public class OtpAuthenticationFilterTest {
         when(request.isSecure()).thenReturn(true);
         
when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN);
         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);
         assertEquals(DOWNLOAD_TOKEN, result.getToken());
@@ -131,7 +131,7 @@ public class OtpAuthenticationFilterTest {
         when(request.isSecure()).thenReturn(true);
         
when(request.getParameter(OtpAuthenticationFilter.ACCESS_TOKEN)).thenReturn(DOWNLOAD_TOKEN);
         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);
         assertEquals(DOWNLOAD_TOKEN, result.getToken());

Reply via email to