cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [09/51] [abbrv] git commit: updated refs/heads/useraccount-refactoring to 1e25886
Date Fri, 28 Nov 2014 18:03:23 GMT
Merge remote-tracking branch 'origin/inetaddress'

- Tested locally against unit tests
- TravisCI build passed: https://travis-ci.org/apache/cloudstack/builds/41990351
- Manual QA passed for basic auth and saml auth using default IDP settings

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	server/src/com/cloud/api/ApiServlet.java


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7ff31f1b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7ff31f1b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7ff31f1b

Branch: refs/heads/useraccount-refactoring
Commit: 7ff31f1b223fbc54d04a0610013dfdd76a618ed8
Parents: 4e5b3d0 72ba98b
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Tue Nov 25 14:31:23 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Tue Nov 25 14:32:09 2014 +0530

----------------------------------------------------------------------
 .../apache/cloudstack/api/ApiServerService.java |  3 +-
 .../cloudstack/api/auth/APIAuthenticator.java   |  3 +-
 .../contrail/management/MockAccountManager.java |  3 +-
 .../command/GetServiceProviderMetaDataCmd.java  |  3 +-
 .../command/SAML2LoginAPIAuthenticatorCmd.java  |  3 +-
 .../command/SAML2LogoutAPIAuthenticatorCmd.java |  3 +-
 .../GetServiceProviderMetaDataCmdTest.java      |  6 ++--
 .../SAML2LoginAPIAuthenticatorCmdTest.java      |  5 +--
 .../SAML2LogoutAPIAuthenticatorCmdTest.java     |  3 +-
 pom.xml                                         |  6 ++++
 server/src/com/cloud/api/ApiServer.java         |  2 +-
 server/src/com/cloud/api/ApiServlet.java        |  7 +++--
 .../auth/DefaultLoginAPIAuthenticatorCmd.java   |  3 +-
 .../auth/DefaultLogoutAPIAuthenticatorCmd.java  |  3 +-
 server/src/com/cloud/user/AccountManager.java   |  3 +-
 .../src/com/cloud/user/AccountManagerImpl.java  | 12 +++-----
 server/test/com/cloud/api/ApiServletTest.java   | 14 +++++----
 .../com/cloud/user/MockAccountManagerImpl.java  |  3 +-
 utils/pom.xml                                   |  4 +++
 utils/src/com/cloud/utils/net/NetUtils.java     | 32 ++------------------
 20 files changed, 60 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ff31f1b/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiServer.java
index b335a66,435efa0..435efa0
mode 100644,100755..100644
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ff31f1b/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/api/ApiServlet.java
index e1f7927,a4266f7..3c73375
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@@ -18,10 -18,8 +18,11 @@@ package com.cloud.api
  
  import java.io.UnsupportedEncodingException;
  import java.net.URLDecoder;
 +import java.util.Arrays;
 +import java.util.Collections;
+ import java.net.InetAddress;
  import java.util.HashMap;
 +import java.util.List;
  import java.util.Map;
  
  import javax.inject.Inject;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ff31f1b/server/src/com/cloud/user/AccountManager.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/user/AccountManager.java
index 194c5d2,7b9e093..7b9e093
mode 100644,100755..100644
--- a/server/src/com/cloud/user/AccountManager.java
+++ b/server/src/com/cloud/user/AccountManager.java

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ff31f1b/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/user/AccountManagerImpl.java
index 3c00f91,f816ee4..f816ee4
mode 100644,100755..100644
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ff31f1b/server/test/com/cloud/api/ApiServletTest.java
----------------------------------------------------------------------
diff --cc server/test/com/cloud/api/ApiServletTest.java
index 2089477,1d20bdf..57caa44
--- a/server/test/com/cloud/api/ApiServletTest.java
+++ b/server/test/com/cloud/api/ApiServletTest.java
@@@ -84,10 -83,9 +86,10 @@@ public class ApiServletTest 
  
      ApiServlet servlet;
  
 +    @SuppressWarnings("unchecked")
      @Before
      public void setup() throws SecurityException, NoSuchFieldException,
-             IllegalArgumentException, IllegalAccessException, IOException {
+             IllegalArgumentException, IllegalAccessException, IOException, UnknownHostException
{
          servlet = new ApiServlet();
          responseWriter = new StringWriter();
          Mockito.when(response.getWriter()).thenReturn(
@@@ -196,9 -194,8 +198,9 @@@
                  Mockito.any(StringBuilder.class));
      }
  
 +    @SuppressWarnings("unchecked")
      @Test
-     public void processRequestInContextLogout() {
+     public void processRequestInContextLogout() throws UnknownHostException {
          Mockito.when(request.getMethod()).thenReturn("GET");
          Mockito.when(request.getSession(Mockito.anyBoolean())).thenReturn(
                  session);
@@@ -237,37 -234,6 +239,37 @@@
  
          Mockito.verify(authManager).getAPIAuthenticator("login");
          Mockito.verify(authenticator).authenticate(Mockito.anyString(), Mockito.anyMap(),
Mockito.isA(HttpSession.class),
-                 Mockito.anyString(), Mockito.anyString(), Mockito.isA(StringBuilder.class),
Mockito.isA(HttpServletResponse.class));
+                 Mockito.eq(InetAddress.getByName("127.0.0.1")), Mockito.anyString(), Mockito.isA(StringBuilder.class),
Mockito.isA(HttpServletResponse.class));
      }
 +
 +    @Test
 +    public void getClientAddressWithXForwardedFor() {
 +        Mockito.when(request.getHeader(Mockito.eq("X-Forwarded-For"))).thenReturn("192.168.1.1");
 +        Assert.assertEquals("192.168.1.1", ApiServlet.getClientAddress(request));
 +    }
 +
 +    @Test
 +    public void getClientAddressWithHttpXForwardedFor() {
 +        Mockito.when(request.getHeader(Mockito.eq("HTTP_X_FORWARDED_FOR"))).thenReturn("192.168.1.1");
 +        Assert.assertEquals("192.168.1.1", ApiServlet.getClientAddress(request));
 +    }
 +
 +    @Test
 +    public void getClientAddressWithXRemoteAddr() {
 +        Mockito.when(request.getHeader(Mockito.eq("Remote_Addr"))).thenReturn("192.168.1.1");
 +        Assert.assertEquals("192.168.1.1", ApiServlet.getClientAddress(request));
 +    }
 +
 +    @Test
 +    public void getClientAddressWithHttpClientIp() {
 +        Mockito.when(request.getHeader(Mockito.eq("HTTP_CLIENT_IP"))).thenReturn("192.168.1.1");
 +        Assert.assertEquals("192.168.1.1", ApiServlet.getClientAddress(request));
 +    }
 +
 +    @Test
 +    public void getClientAddressDefault() {
 +        Mockito.when(request.getRemoteAddr()).thenReturn("127.0.0.1");
 +        Assert.assertEquals("127.0.0.1", ApiServlet.getClientAddress(request));
 +    }
 +
  }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ff31f1b/utils/src/com/cloud/utils/net/NetUtils.java
----------------------------------------------------------------------
diff --cc utils/src/com/cloud/utils/net/NetUtils.java
index 1f41825,8875bb9..8875bb9
mode 100644,100755..100644
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java


Mime
View raw message