Package com.vmware.bdd.cli.auth

Examples of com.vmware.bdd.cli.auth.LoginResponse


   }

   @Test
   public void testRelogin() throws IOException {
      Mockito.when(loginClient.login(Matchers.anyString(), Matchers.anyString(), Matchers.anyString())).thenReturn(
            new LoginResponse(200, "JSESSIONID=B6926322AF4D8A8B9CEF3906D5735D41"));

      Connect.ConnectType connectType = restClient.connect("127.0.0.1:8443", "root", "vmware");

      Assert.assertEquals(connectType, Connect.ConnectType.SUCCESS);

      Mockito.when(loginClient.login(Matchers.anyString(), Matchers.anyString(), Matchers.anyString())).thenReturn(
            new LoginResponse(200, null));

      connectType = restClient.connect("127.0.0.1:8443", "root", "vmware");

      Assert.assertEquals(connectType, Connect.ConnectType.SUCCESS);
   }
View Full Code Here


            Constants.HTTPS_CONNECTION_PREFIX + host
                  + Constants.HTTPS_CONNECTION_LOGIN_SUFFIX;

      Connect.ConnectType connectType = null;
      try {
         LoginResponse response = loginClient.login(hostUri, username, password);

         //200
         if (response.getResponseCode() == HttpStatus.OK.value()) {
            if(CommonUtil.isBlank(response.getSessionId())) {
               if (isConnected()) {
                  System.out.println(Constants.CONNECTION_ALREADY_ESTABLISHED);
                  connectType = Connect.ConnectType.SUCCESS;
               } else {
                  System.out.println(Constants.CONNECT_FAILURE_NO_SESSION_ID);
                  connectType = Connect.ConnectType.ERROR;
               }
            } else {
               //normal response
               updateHostProperty(host);

               writeCookieInfo(response.getSessionId());
               System.out.println(Constants.CONNECT_SUCCESS);
               connectType = Connect.ConnectType.SUCCESS;
            }
         }
         //401
         else if(response.getResponseCode() == HttpStatus.UNAUTHORIZED.value()) {
            System.out.println(Constants.CONNECT_UNAUTHORIZATION_CONNECT);
            //recover old hostUri
            hostUri = oldHostUri;
            connectType = Connect.ConnectType.UNAUTHORIZATION;
         }
         //500
         else if(response.getResponseCode() == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
            System.out.println(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
            connectType = Connect.ConnectType.ERROR;
         } else {
            //error
            System.out.println(
                  String.format(
                  Constants.UNSUPPORTED_HTTP_RESPONSE_CODE, response.getResponseCode()));
            //recover old hostUri
            hostUri = oldHostUri;
            connectType = Connect.ConnectType.ERROR;
         }
      } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.vmware.bdd.cli.auth.LoginResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.