You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/07/01 21:14:53 UTC

[06/24] JCLOUDS-151 - CloudStack refactored to remove async, *Client renamed to *Api.

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiExpectTest.java
new file mode 100644
index 0000000..086ab54
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiExpectTest.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.cloudstack.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import org.jclouds.cloudstack.CloudStackApiMetadata;
+import org.jclouds.cloudstack.CloudStackContext;
+import org.jclouds.cloudstack.domain.SshKeyPair;
+import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.ssh.SshKeys;
+import org.jclouds.util.Strings2;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Test the CloudStack SSHKeyPairApi
+ *
+ * @author Andrei Savu
+ */
+@Test(groups = "unit", testName = "SSHKeyPairApiExpectTest")
+public class SSHKeyPairApiExpectTest extends BaseCloudStackExpectTest<SSHKeyPairApi> {
+
+   @Test
+   public void testListAndGetSSHKeyPairsWhenResponseIs2xx() {
+      HttpResponse response = HttpResponse.builder()
+         .statusCode(200)
+         .payload(payloadFromResource("/listsshkeypairsresponse.json"))
+         .build();
+
+      SSHKeyPairApi client = requestSendsResponse(HttpRequest.builder()
+         .method("GET")
+         .endpoint(
+            URI.create("http://localhost:8080/client/api?response=json&" +
+               "command=listSSHKeyPairs&listAll=true&apiKey=identity&signature=5d2J9u%2BdKpkQsadDbl9i9OcUSLQ%3D"))
+            .addHeader("Accept", "application/json")
+         .build(), response);
+
+      assertEquals(client.listSSHKeyPairs(), ImmutableSet.of(
+         SshKeyPair.builder().name("jclouds-keypair")
+            .fingerprint("1c:06:74:52:3b:99:1c:95:5c:04:c2:f4:ba:77:6e:7b").build()));
+
+      client = requestSendsResponse(HttpRequest.builder()
+         .method("GET")
+         .endpoint(
+            URI.create("http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&" +
+               "name=jclouds-keypair&apiKey=identity&signature=hJIVCFOHhdOww3aq19tFHpeD2HI%3D"))
+            .addHeader("Accept", "application/json")
+         .build(), response);
+
+      assertEquals(client.getSSHKeyPair("jclouds-keypair"),
+         SshKeyPair.builder().name("jclouds-keypair")
+            .fingerprint("1c:06:74:52:3b:99:1c:95:5c:04:c2:f4:ba:77:6e:7b").build());
+   }
+
+   @Test
+   public void testCreateSSHKeyPairsWhenResponseIs2xx() {
+      SSHKeyPairApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&command=createSSHKeyPair&" +
+                  "name=jclouds-keypair&apiKey=identity&signature=8wk32PZF44jrBLH2HLel22%2BqMC4%3D"))
+            .addHeader("Accept", "application/json")
+            .build(),
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/createsshkeypairresponse.json"))
+            .build());
+
+      SshKeyPair actual = client.createSSHKeyPair("jclouds-keypair");
+      SshKeyPair expected = SshKeyPair.builder().name("jclouds-keypair")
+         .fingerprint("1c:06:74:52:3b:99:1c:95:5c:04:c2:f4:ba:77:6e:7b")
+         .privateKey("-----BEGIN RSA PRIVATE KEY-----\n" +
+            "MIICXgIBAAKBgQDZo/EF4Ew1uEW0raz7vCs28lBwy0UKV2Xr606gaEgxO7h9mSXZ\n" +
+            "4x2K/KQ1NMnrbjppxGycLh9EKPWAO3ezFULAyuOZW4Fy+xRS8+3MAijxBJY/KBgl\n" +
+            "x5rJm2ILumRkTNkMlLGCSBb9SOqYRN1VpOy7kn3StzU9LdJ/snKVE2JLHQIDAQAB\n" +
+            "AoGBAMnL5okKRd9xcsBqYIAxIuiZmNhcwTErhEdRMOAukPGFbDSYsa3rldLvGdpz\n" +
+            "jd2LoQG8rO/LHBZ429kASqZzyiV+NvcgH+tFNJSVAigjSICfhEKF9PY2TiAkrg7S\n" +
+            "GyJgAjpPWQc2sQh0dE8EPEtBiq4ibXfMTDmbs1d/vnfdwtQJAkEA+AX5Y+xgWj74\n" +
+            "dYETmNLyLhNZpftLizEfIYj7lCVhsbFwVb8jbM1m8n8bxwGjls1w/ico1CWcQna+\n" +
+            "UnAfA8kJvwJBAOCj0YgDKpYd0OLQhvI3212J9QcQpJEkDOTYiMwXNHCNMKRpoF47\n" +
+            "MPPX+GG8YzUiQAi9/OG4pDKCjzQWE/ebiiMCQQCssnQ5WICqtggIwYykr9VDseON\n" +
+            "SFIMpHJ5xkjumazRrqx6eDGxc8BH/6uWwRRoT7pqrVeniFyqhsX03u8pkpU/AkBj\n" +
+            "WfCcwBHArNUqy2EzlWKuvwogosq16oTNXbs60HR/5uIBhTnJE1K2NemDiGc0I77A\n" +
+            "Xw6N4jS0piuhtLYGB8OTAkEA50abdbduXWcr62Z6E8G/6LNFaNg0uBuVgwSHtJMd\n" +
+            "dNeUtVDHQCHSf3tvxXTAtaB9PCnGOfgm/dyYWEMf3rMoHQ==\n" +
+            "-----END RSA PRIVATE KEY-----\n")
+         .build();
+
+      assertEquals(actual, expected);
+      assertEquals(SshKeys.fingerprintPrivateKey(actual.getPrivateKey()), expected.getFingerprint());
+   }
+
+   @Test
+   public void testRegisterSSHKeyPairWhenResponseIs2xx() throws UnsupportedEncodingException {
+      String publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCc903twxU2zcQnIJdXv61RwZNZW94uId9qz08fgsBJsCOnHNIC4+L9kDOA2IHV9cUfEDBm1Be5TbpadWwSbS/05E+FARH2/MCO932UgcKUq5PGymS0249fLCBPci5zoLiG5vIym+1ij1hL/nHvkK99NIwe7io+Lmp9OcF3PTsm3Rgh5T09cRHGX9horp0VoAVa9vKJx6C1/IEHVnG8p0YPPa1lmemvx5kNBEiyoNQNYa34EiFkcJfP6rqNgvY8h/j4nE9SXoUCC/g6frhMFMOL0tzYqvz0Lczqm1Oh4RnSn3O9X4R934p28qqAobe337hmlLUdb6H5zuf+NwCh0HdZ";
+
+      String privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" +
+         "MIIEpQIBAAKCAQEAnPdN7cMVNs3EJyCXV7+tUcGTWVveLiHfas9PH4LASbAjpxzS\n" +
+         "AuPi/ZAzgNiB1fXFHxAwZtQXuU26WnVsEm0v9ORPhQER9vzAjvd9lIHClKuTxspk\n" +
+         "tNuPXywgT3Iuc6C4hubyMpvtYo9YS/5x75CvfTSMHu4qPi5qfTnBdz07Jt0YIeU9\n" +
+         "PXERxl/YaK6dFaAFWvbyicegtfyBB1ZxvKdGDz2tZZnpr8eZDQRIsqDUDWGt+BIh\n" +
+         "ZHCXz+q6jYL2PIf4+JxPUl6FAgv4On64TBTDi9Lc2Kr89C3M6ptToeEZ0p9zvV+E\n" +
+         "fd+KdvKqgKG3t9+4ZpS1HW+h+c7n/jcAodB3WQIDAQABAoIBAQCX+iKr2LzLiUMo\n" +
+         "lzexsFbB1+kxFe/zPryxD/QOEGzZa/+5KAB25+q5k0sqr3ZWkVXAk84pYaVut0F9\n" +
+         "oD95P9q1A/GyV6zrNSHDywD+Lv0VMWMtkH0dV5Bjl7fY9DbhoXXIuAc81Rhs21mk\n" +
+         "isIKME6Zra0VrYedGRfmE2usZc7F+rrnJeWs2edk1Q/lBLIe/v+NfRrO0fpHPu8S\n" +
+         "9/kbVM3fUwHXxVTbvzZjjerQcLyEr4nT53DcSQJcm3e2DGsdRr5FBxkOXlcWElew\n" +
+         "pbGM+RiF7RJvPW8lrmGj4y7Eo7TmfW8Yc5MM5A/PcvvxuRTRurmqOA5Wl1Bsp8/o\n" +
+         "PEU/p9G5AoGBANcBOz0vSj+NOFip9gbc2WPVFpaoCT51DBQsT9R4kxe34Ltbwqaj\n" +
+         "QXMiBjgereSM/KXTriA/Lhkj09YI5OAgk64PXcmDc2urMiFlewqxld79GDLAFwqn\n" +
+         "nsEm1YTjY8wujw2J5Fbp7BZFHCrfld5L8xhgSb135YEa1/4LGOg+o6FDAoGBALrl\n" +
+         "GL/v8ZDc2l/GpGsOA7360s9lRUhCTlQ86am8Lw/AdMSdpi9Is3yCdZx1NWDpUEKz\n" +
+         "MBQTfiEEzpYlujvdUQNyQ4JGuhU/J7JEqEP2rfXaXjn0PIThkWFuNRkyK6Pz0rsT\n" +
+         "4YJQouI7PCDE3BZxY4WYZ4uBZpCf3YC5SZiwtl0zAoGBAJGNnNwD+sDhSscDcLIe\n" +
+         "qvDh3iPp6DAnLyEtCnItmm7RJcvRCAqltPZLj2hIpLJ4G8XrcxMTkpKkZZGdfcyZ\n" +
+         "YUDR2E1Gt0mpoQto1w5bQLmwH8SjtDWbWmcqchw/kF03G9MviaypOhGtga8opB3U\n" +
+         "zuKutN0WoQFw+c5bFuaLGV1fAoGABdFLy+20H0ZApeqRA6QUCb3dAges+GrX9VdQ\n" +
+         "DrCE5oCfId+mZKJms+F7t7sORk386ZaaUIWqz2xO4e2atnJVKz5LS6rX8AFfQvVQ\n" +
+         "J41uLND3TeaEW76Jv/amQHqHUTstvBUKV/waleAyJvL5xtkQt//eeUE16BqR0ofx\n" +
+         "+obFpnECgYEAuDT1vH9JcGhD/iX4qLhS1xS1fXJh4IYvt8bg8oLRyRBqF6x9uhx3\n" +
+         "6v+WQaKHyGvebWRN+SKAsKQHsh8a7Iy7xZdZmQ8v9j4DcYwJMb7ksV//R2kXAPGL\n" +
+         "BTfRj1MSI+6AsuVY/YF1O2AfGneP+Zn5bQwYzQkxOYjzF9bhZz3IniE=\n" +
+         "-----END RSA PRIVATE KEY-----\n";
+
+      // Compute the fingerprint by using the following command:  ssh-keygen -lf key.pub
+      String expectedFingerprint = "8f:f1:91:2d:b1:a8:51:f1:79:cf:c4:31:c4:14:9d:81";
+      
+      assertTrue(SshKeys.privateKeyMatchesPublicKey(privateKey, publicKey));
+      assertEquals(SshKeys.fingerprintPublicKey(publicKey), expectedFingerprint);
+      assertEquals(SshKeys.fingerprintPrivateKey(privateKey), expectedFingerprint);
+      
+      SSHKeyPairApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&command=registerSSHKeyPair&" +
+                  "name=jclouds-keypair&publickey=" + Strings2.urlEncode(publicKey, '/') +
+                  "&apiKey=identity&signature=g/6BXLnnvOMlKQBp1yM7GKlvfus%3D"))
+            .headers(
+               ImmutableMultimap.<String, String>builder()
+                  .put("Accept", "application/json")
+                  .build())
+            .build(),
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/registersshkeypairresponse.json"))
+            .build());
+
+      SshKeyPair actual = client.registerSSHKeyPair("jclouds-keypair", publicKey);
+      SshKeyPair expected = SshKeyPair.builder().name("jclouds-keypair")
+         .fingerprint(expectedFingerprint).build();
+
+      assertEquals(actual, expected);
+      assertEquals(expectedFingerprint, expected.getFingerprint());
+   }
+
+   @Override
+   protected SSHKeyPairApi clientFrom(CloudStackContext context) {
+      return context.getApi().getSSHKeyPairApi();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiLiveTest.java
new file mode 100644
index 0000000..03721db
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiLiveTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.cloudstack.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.cloudstack.domain.SshKeyPair;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest;
+import org.jclouds.ssh.SshKeys;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code SSHKeyPairApi}
+ *
+ * @author Vijay Kiran
+ */
+@Test(groups = "live", singleThreaded = true, testName = "SSHKeyPairApiLiveTest")
+public class SSHKeyPairApiLiveTest extends BaseCloudStackApiLiveTest {
+
+   protected String prefix = System.getProperty("user.name");
+   private String keyPairName = prefix + "-jclouds-keypair";
+   private SshKeyPair sshKeyPair;
+
+   @BeforeMethod
+   @AfterMethod
+   public void removeExistingKey() {
+      client.getSSHKeyPairApi().deleteSSHKeyPair(keyPairName);
+   }
+
+   @Test
+   public void testListSSHKeyPairs() {
+      final Set<SshKeyPair> sshKeyPairs = client.getSSHKeyPairApi().listSSHKeyPairs();
+      for (SshKeyPair sshKeyPair : sshKeyPairs) {
+         checkSSHKeyPair(sshKeyPair);
+      }
+   }
+
+   @Test
+   public void testCreateDeleteSSHKeyPair() {
+      sshKeyPair = client.getSSHKeyPairApi().createSSHKeyPair(keyPairName);
+      assertNotNull(sshKeyPair.getPrivateKey());
+      checkSSHKeyPair(sshKeyPair);
+      client.getSSHKeyPairApi().deleteSSHKeyPair(sshKeyPair.getName());
+
+      assertEquals(client.getSSHKeyPairApi().getSSHKeyPair(sshKeyPair.getName()), null);
+      assertEquals(SshKeys.fingerprintPrivateKey(sshKeyPair.getPrivateKey()), sshKeyPair.getFingerprint());
+
+      sshKeyPair = null;
+   }
+
+   @Test
+   public void testRegisterDeleteSSHKeyPair() {
+      final Map<String, String> sshKey = SshKeys.generate();
+      final String publicKey = sshKey.get("public");
+
+      sshKeyPair = client.getSSHKeyPairApi().registerSSHKeyPair(keyPairName, publicKey);
+      assertNull(sshKeyPair.getPrivateKey());
+      checkSSHKeyPair(sshKeyPair);
+      client.getSSHKeyPairApi().deleteSSHKeyPair(keyPairName);
+
+      assertEquals(client.getSSHKeyPairApi().getSSHKeyPair(sshKeyPair.getName()), null);
+      assertEquals(SshKeys.fingerprintPublicKey(publicKey), sshKeyPair.getFingerprint());
+
+      sshKeyPair = null;
+   }
+
+   protected void checkSSHKeyPair(SshKeyPair pair) {
+      assert pair.getName() != null : pair;
+      assertEquals(pair.getFingerprint(),
+         client.getSSHKeyPairApi().getSSHKeyPair(pair.getName()).getFingerprint());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiTest.java
new file mode 100644
index 0000000..da46290
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiTest.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.cloudstack.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.cloudstack.filters.QuerySigner;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiTest;
+import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.functions.IdentityFunction;
+import org.jclouds.http.functions.ParseFirstJsonValueNamed;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.ssh.SshKeys;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Functions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code SSHKeyPairApi}
+ *
+ * @author Vijay Kiran
+ */
+@Test(groups = "unit", testName = "SSHKeyPairApiTest")
+public class SSHKeyPairApiTest extends BaseCloudStackApiTest<SSHKeyPairApi> {
+
+   public void testListSSHKeyPairs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SSHKeyPairApi.class, "listSSHKeyPairs", ListSSHKeyPairsOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testListSSHKeyPairsOptions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SSHKeyPairApi.class, "listSSHKeyPairs", ListSSHKeyPairsOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListSSHKeyPairsOptions.Builder.name("jclouds")));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&name=jclouds HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testGetSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SSHKeyPairApi.class, "getSSHKeyPair", String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair"));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&name=jclouds-keypair HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest,
+            Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testRegisterSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SSHKeyPairApi.class, "registerSSHKeyPair", String.class, String.class);
+      String publicKey = URLEncoder.encode(SshKeys.generate().get("public"), "UTF-8");
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair", publicKey));
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=registerSSHKeyPair&name=jclouds-keypair&publickey="
+                  + publicKey
+                  + " HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      assertEquals(httpRequest.getFilters().size(), 1);
+      assertEquals(httpRequest.getFilters().get(0).getClass(), QuerySigner.class);
+   }
+
+
+   public void testDeleteSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SSHKeyPairApi.class, "deleteSSHKeyPair", String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair"));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=deleteSSHKeyPair&name=jclouds-keypair HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java
deleted file mode 100644
index 2d06745..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.cloudstack.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URLEncoder;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.cloudstack.filters.QuerySigner;
-import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
-import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions;
-import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
-import org.jclouds.functions.IdentityFunction;
-import org.jclouds.http.functions.ParseFirstJsonValueNamed;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.ssh.SshKeys;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Functions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code SSHKeyPairAsyncClient}
- *
- * @author Vijay Kiran
- */
-@Test(groups = "unit", testName = "SSHKeyPairAsyncClientTest")
-public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSHKeyPairAsyncClient> {
-
-   public void testListSSHKeyPairs() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(SSHKeyPairAsyncClient.class, "listSSHKeyPairs", ListSSHKeyPairsOptions[].class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
-      checkFilters(httpRequest);
-
-   }
-
-   public void testListSSHKeyPairsOptions() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(SSHKeyPairAsyncClient.class, "listSSHKeyPairs", ListSSHKeyPairsOptions[].class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListSSHKeyPairsOptions.Builder.name("jclouds")));
-
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&name=jclouds HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
-      checkFilters(httpRequest);
-
-   }
-
-   public void testGetSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(SSHKeyPairAsyncClient.class, "getSSHKeyPair", String.class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair"));
-
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&name=jclouds-keypair HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest,
-            Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
-      checkFilters(httpRequest);
-
-   }
-
-   public void testRegisterSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(SSHKeyPairAsyncClient.class, "registerSSHKeyPair", String.class, String.class);
-      String publicKey = URLEncoder.encode(SshKeys.generate().get("public"), "UTF-8");
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair", publicKey));
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&command=registerSSHKeyPair&name=jclouds-keypair&publickey="
-                  + publicKey
-                  + " HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
-      assertEquals(httpRequest.getFilters().size(), 1);
-      assertEquals(httpRequest.getFilters().get(0).getClass(), QuerySigner.class);
-   }
-
-
-   public void testDeleteSSHKeyPair() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(SSHKeyPairAsyncClient.class, "deleteSSHKeyPair", String.class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("jclouds-keypair"));
-
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&command=deleteSSHKeyPair&name=jclouds-keypair HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
-      checkFilters(httpRequest);
-   }
-}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientExpectTest.java
deleted file mode 100644
index b041907..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientExpectTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.cloudstack.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import org.jclouds.cloudstack.CloudStackApiMetadata;
-import org.jclouds.cloudstack.CloudStackContext;
-import org.jclouds.cloudstack.domain.SshKeyPair;
-import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.ssh.SshKeys;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Test the CloudStack SSHKeyPairClient
- *
- * @author Andrei Savu
- */
-@Test(groups = "unit", testName = "SSHKeyPairClientExpectTest")
-public class SSHKeyPairClientExpectTest extends BaseCloudStackExpectTest<SSHKeyPairClient> {
-
-   @Test
-   public void testListAndGetSSHKeyPairsWhenResponseIs2xx() {
-      HttpResponse response = HttpResponse.builder()
-         .statusCode(200)
-         .payload(payloadFromResource("/listsshkeypairsresponse.json"))
-         .build();
-
-      SSHKeyPairClient client = requestSendsResponse(HttpRequest.builder()
-         .method("GET")
-         .endpoint(
-            URI.create("http://localhost:8080/client/api?response=json&" +
-               "command=listSSHKeyPairs&listAll=true&apiKey=identity&signature=5d2J9u%2BdKpkQsadDbl9i9OcUSLQ%3D"))
-            .addHeader("Accept", "application/json")
-         .build(), response);
-
-      assertEquals(client.listSSHKeyPairs(), ImmutableSet.of(
-         SshKeyPair.builder().name("jclouds-keypair")
-            .fingerprint("1c:06:74:52:3b:99:1c:95:5c:04:c2:f4:ba:77:6e:7b").build()));
-
-      client = requestSendsResponse(HttpRequest.builder()
-         .method("GET")
-         .endpoint(
-            URI.create("http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&" +
-               "name=jclouds-keypair&apiKey=identity&signature=hJIVCFOHhdOww3aq19tFHpeD2HI%3D"))
-            .addHeader("Accept", "application/json")
-         .build(), response);
-
-      assertEquals(client.getSSHKeyPair("jclouds-keypair"),
-         SshKeyPair.builder().name("jclouds-keypair")
-            .fingerprint("1c:06:74:52:3b:99:1c:95:5c:04:c2:f4:ba:77:6e:7b").build());
-   }
-
-   @Test
-   public void testCreateSSHKeyPairsWhenResponseIs2xx() {
-      SSHKeyPairClient client = requestSendsResponse(
-         HttpRequest.builder()
-            .method("GET")
-            .endpoint(
-               URI.create("http://localhost:8080/client/api?response=json&command=createSSHKeyPair&" +
-                  "name=jclouds-keypair&apiKey=identity&signature=8wk32PZF44jrBLH2HLel22%2BqMC4%3D"))
-            .addHeader("Accept", "application/json")
-            .build(),
-         HttpResponse.builder()
-            .statusCode(200)
-            .payload(payloadFromResource("/createsshkeypairresponse.json"))
-            .build());
-
-      SshKeyPair actual = client.createSSHKeyPair("jclouds-keypair");
-      SshKeyPair expected = SshKeyPair.builder().name("jclouds-keypair")
-         .fingerprint("1c:06:74:52:3b:99:1c:95:5c:04:c2:f4:ba:77:6e:7b")
-         .privateKey("-----BEGIN RSA PRIVATE KEY-----\n" +
-            "MIICXgIBAAKBgQDZo/EF4Ew1uEW0raz7vCs28lBwy0UKV2Xr606gaEgxO7h9mSXZ\n" +
-            "4x2K/KQ1NMnrbjppxGycLh9EKPWAO3ezFULAyuOZW4Fy+xRS8+3MAijxBJY/KBgl\n" +
-            "x5rJm2ILumRkTNkMlLGCSBb9SOqYRN1VpOy7kn3StzU9LdJ/snKVE2JLHQIDAQAB\n" +
-            "AoGBAMnL5okKRd9xcsBqYIAxIuiZmNhcwTErhEdRMOAukPGFbDSYsa3rldLvGdpz\n" +
-            "jd2LoQG8rO/LHBZ429kASqZzyiV+NvcgH+tFNJSVAigjSICfhEKF9PY2TiAkrg7S\n" +
-            "GyJgAjpPWQc2sQh0dE8EPEtBiq4ibXfMTDmbs1d/vnfdwtQJAkEA+AX5Y+xgWj74\n" +
-            "dYETmNLyLhNZpftLizEfIYj7lCVhsbFwVb8jbM1m8n8bxwGjls1w/ico1CWcQna+\n" +
-            "UnAfA8kJvwJBAOCj0YgDKpYd0OLQhvI3212J9QcQpJEkDOTYiMwXNHCNMKRpoF47\n" +
-            "MPPX+GG8YzUiQAi9/OG4pDKCjzQWE/ebiiMCQQCssnQ5WICqtggIwYykr9VDseON\n" +
-            "SFIMpHJ5xkjumazRrqx6eDGxc8BH/6uWwRRoT7pqrVeniFyqhsX03u8pkpU/AkBj\n" +
-            "WfCcwBHArNUqy2EzlWKuvwogosq16oTNXbs60HR/5uIBhTnJE1K2NemDiGc0I77A\n" +
-            "Xw6N4jS0piuhtLYGB8OTAkEA50abdbduXWcr62Z6E8G/6LNFaNg0uBuVgwSHtJMd\n" +
-            "dNeUtVDHQCHSf3tvxXTAtaB9PCnGOfgm/dyYWEMf3rMoHQ==\n" +
-            "-----END RSA PRIVATE KEY-----\n")
-         .build();
-
-      assertEquals(actual, expected);
-      assertEquals(SshKeys.fingerprintPrivateKey(actual.getPrivateKey()), expected.getFingerprint());
-   }
-
-   @Test
-   public void testRegisterSSHKeyPairWhenResponseIs2xx() throws UnsupportedEncodingException {
-      String publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCc903twxU2zcQnIJdXv61RwZNZW94uId9qz08fgsBJsCOnHNIC4+L9kDOA2IHV9cUfEDBm1Be5TbpadWwSbS/05E+FARH2/MCO932UgcKUq5PGymS0249fLCBPci5zoLiG5vIym+1ij1hL/nHvkK99NIwe7io+Lmp9OcF3PTsm3Rgh5T09cRHGX9horp0VoAVa9vKJx6C1/IEHVnG8p0YPPa1lmemvx5kNBEiyoNQNYa34EiFkcJfP6rqNgvY8h/j4nE9SXoUCC/g6frhMFMOL0tzYqvz0Lczqm1Oh4RnSn3O9X4R934p28qqAobe337hmlLUdb6H5zuf+NwCh0HdZ";
-
-      String privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" +
-         "MIIEpQIBAAKCAQEAnPdN7cMVNs3EJyCXV7+tUcGTWVveLiHfas9PH4LASbAjpxzS\n" +
-         "AuPi/ZAzgNiB1fXFHxAwZtQXuU26WnVsEm0v9ORPhQER9vzAjvd9lIHClKuTxspk\n" +
-         "tNuPXywgT3Iuc6C4hubyMpvtYo9YS/5x75CvfTSMHu4qPi5qfTnBdz07Jt0YIeU9\n" +
-         "PXERxl/YaK6dFaAFWvbyicegtfyBB1ZxvKdGDz2tZZnpr8eZDQRIsqDUDWGt+BIh\n" +
-         "ZHCXz+q6jYL2PIf4+JxPUl6FAgv4On64TBTDi9Lc2Kr89C3M6ptToeEZ0p9zvV+E\n" +
-         "fd+KdvKqgKG3t9+4ZpS1HW+h+c7n/jcAodB3WQIDAQABAoIBAQCX+iKr2LzLiUMo\n" +
-         "lzexsFbB1+kxFe/zPryxD/QOEGzZa/+5KAB25+q5k0sqr3ZWkVXAk84pYaVut0F9\n" +
-         "oD95P9q1A/GyV6zrNSHDywD+Lv0VMWMtkH0dV5Bjl7fY9DbhoXXIuAc81Rhs21mk\n" +
-         "isIKME6Zra0VrYedGRfmE2usZc7F+rrnJeWs2edk1Q/lBLIe/v+NfRrO0fpHPu8S\n" +
-         "9/kbVM3fUwHXxVTbvzZjjerQcLyEr4nT53DcSQJcm3e2DGsdRr5FBxkOXlcWElew\n" +
-         "pbGM+RiF7RJvPW8lrmGj4y7Eo7TmfW8Yc5MM5A/PcvvxuRTRurmqOA5Wl1Bsp8/o\n" +
-         "PEU/p9G5AoGBANcBOz0vSj+NOFip9gbc2WPVFpaoCT51DBQsT9R4kxe34Ltbwqaj\n" +
-         "QXMiBjgereSM/KXTriA/Lhkj09YI5OAgk64PXcmDc2urMiFlewqxld79GDLAFwqn\n" +
-         "nsEm1YTjY8wujw2J5Fbp7BZFHCrfld5L8xhgSb135YEa1/4LGOg+o6FDAoGBALrl\n" +
-         "GL/v8ZDc2l/GpGsOA7360s9lRUhCTlQ86am8Lw/AdMSdpi9Is3yCdZx1NWDpUEKz\n" +
-         "MBQTfiEEzpYlujvdUQNyQ4JGuhU/J7JEqEP2rfXaXjn0PIThkWFuNRkyK6Pz0rsT\n" +
-         "4YJQouI7PCDE3BZxY4WYZ4uBZpCf3YC5SZiwtl0zAoGBAJGNnNwD+sDhSscDcLIe\n" +
-         "qvDh3iPp6DAnLyEtCnItmm7RJcvRCAqltPZLj2hIpLJ4G8XrcxMTkpKkZZGdfcyZ\n" +
-         "YUDR2E1Gt0mpoQto1w5bQLmwH8SjtDWbWmcqchw/kF03G9MviaypOhGtga8opB3U\n" +
-         "zuKutN0WoQFw+c5bFuaLGV1fAoGABdFLy+20H0ZApeqRA6QUCb3dAges+GrX9VdQ\n" +
-         "DrCE5oCfId+mZKJms+F7t7sORk386ZaaUIWqz2xO4e2atnJVKz5LS6rX8AFfQvVQ\n" +
-         "J41uLND3TeaEW76Jv/amQHqHUTstvBUKV/waleAyJvL5xtkQt//eeUE16BqR0ofx\n" +
-         "+obFpnECgYEAuDT1vH9JcGhD/iX4qLhS1xS1fXJh4IYvt8bg8oLRyRBqF6x9uhx3\n" +
-         "6v+WQaKHyGvebWRN+SKAsKQHsh8a7Iy7xZdZmQ8v9j4DcYwJMb7ksV//R2kXAPGL\n" +
-         "BTfRj1MSI+6AsuVY/YF1O2AfGneP+Zn5bQwYzQkxOYjzF9bhZz3IniE=\n" +
-         "-----END RSA PRIVATE KEY-----\n";
-
-      // Compute the fingerprint by using the following command:  ssh-keygen -lf key.pub
-      String expectedFingerprint = "8f:f1:91:2d:b1:a8:51:f1:79:cf:c4:31:c4:14:9d:81";
-      
-      assertTrue(SshKeys.privateKeyMatchesPublicKey(privateKey, publicKey));
-      assertEquals(SshKeys.fingerprintPublicKey(publicKey), expectedFingerprint);
-      assertEquals(SshKeys.fingerprintPrivateKey(privateKey), expectedFingerprint);
-      
-      SSHKeyPairClient client = requestSendsResponse(
-         HttpRequest.builder()
-            .method("GET")
-            .endpoint(
-               URI.create("http://localhost:8080/client/api?response=json&command=registerSSHKeyPair&" +
-                  "name=jclouds-keypair&publickey=" + Strings2.urlEncode(publicKey, '/') +
-                  "&apiKey=identity&signature=g/6BXLnnvOMlKQBp1yM7GKlvfus%3D"))
-            .headers(
-               ImmutableMultimap.<String, String>builder()
-                  .put("Accept", "application/json")
-                  .build())
-            .build(),
-         HttpResponse.builder()
-            .statusCode(200)
-            .payload(payloadFromResource("/registersshkeypairresponse.json"))
-            .build());
-
-      SshKeyPair actual = client.registerSSHKeyPair("jclouds-keypair", publicKey);
-      SshKeyPair expected = SshKeyPair.builder().name("jclouds-keypair")
-         .fingerprint(expectedFingerprint).build();
-
-      assertEquals(actual, expected);
-      assertEquals(expectedFingerprint, expected.getFingerprint());
-   }
-
-   @Override
-   protected SSHKeyPairClient clientFrom(CloudStackContext context) {
-      return context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi().getSSHKeyPairClient();
-   }
-}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientLiveTest.java
deleted file mode 100644
index 6da9b6c..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairClientLiveTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.cloudstack.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jclouds.cloudstack.domain.SshKeyPair;
-import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
-import org.jclouds.ssh.SshKeys;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code SSHKeyPairClient}
- *
- * @author Vijay Kiran
- */
-@Test(groups = "live", singleThreaded = true, testName = "SSHKeyPairClientLiveTest")
-public class SSHKeyPairClientLiveTest extends BaseCloudStackClientLiveTest {
-
-   protected String prefix = System.getProperty("user.name");
-   private String keyPairName = prefix + "-jclouds-keypair";
-   private SshKeyPair sshKeyPair;
-
-   @BeforeMethod
-   @AfterMethod
-   public void removeExistingKey() {
-      client.getSSHKeyPairClient().deleteSSHKeyPair(keyPairName);
-   }
-
-   @Test
-   public void testListSSHKeyPairs() {
-      final Set<SshKeyPair> sshKeyPairs = client.getSSHKeyPairClient().listSSHKeyPairs();
-      for (SshKeyPair sshKeyPair : sshKeyPairs) {
-         checkSSHKeyPair(sshKeyPair);
-      }
-   }
-
-   @Test
-   public void testCreateDeleteSSHKeyPair() {
-      sshKeyPair = client.getSSHKeyPairClient().createSSHKeyPair(keyPairName);
-      assertNotNull(sshKeyPair.getPrivateKey());
-      checkSSHKeyPair(sshKeyPair);
-      client.getSSHKeyPairClient().deleteSSHKeyPair(sshKeyPair.getName());
-
-      assertEquals(client.getSSHKeyPairClient().getSSHKeyPair(sshKeyPair.getName()), null);
-      assertEquals(SshKeys.fingerprintPrivateKey(sshKeyPair.getPrivateKey()), sshKeyPair.getFingerprint());
-
-      sshKeyPair = null;
-   }
-
-   @Test
-   public void testRegisterDeleteSSHKeyPair() {
-      final Map<String, String> sshKey = SshKeys.generate();
-      final String publicKey = sshKey.get("public");
-
-      sshKeyPair = client.getSSHKeyPairClient().registerSSHKeyPair(keyPairName, publicKey);
-      assertNull(sshKeyPair.getPrivateKey());
-      checkSSHKeyPair(sshKeyPair);
-      client.getSSHKeyPairClient().deleteSSHKeyPair(keyPairName);
-
-      assertEquals(client.getSSHKeyPairClient().getSSHKeyPair(sshKeyPair.getName()), null);
-      assertEquals(SshKeys.fingerprintPublicKey(publicKey), sshKeyPair.getFingerprint());
-
-      sshKeyPair = null;
-   }
-
-   protected void checkSSHKeyPair(SshKeyPair pair) {
-      assert pair.getName() != null : pair;
-      assertEquals(pair.getFingerprint(),
-         client.getSSHKeyPairClient().getSSHKeyPair(pair.getName()).getFingerprint());
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiLiveTest.java
new file mode 100644
index 0000000..c5fffce
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiLiveTest.java
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.cloudstack.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.NoSuchElementException;
+
+import org.jclouds.cloudstack.domain.IngressRule;
+import org.jclouds.cloudstack.domain.SecurityGroup;
+import org.jclouds.cloudstack.domain.VirtualMachine;
+import org.jclouds.cloudstack.domain.Zone;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest;
+import org.jclouds.cloudstack.options.AccountInDomainOptions;
+import org.jclouds.cloudstack.options.DeployVirtualMachineOptions;
+import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
+import org.jclouds.util.Strings2;
+import org.testng.SkipException;
+import org.testng.annotations.AfterGroups;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.net.HostAndPort;
+
+/**
+ * Tests behavior of {@code SecurityGroupApi}
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "SecurityGroupApiLiveTest")
+public class SecurityGroupApiLiveTest extends BaseCloudStackApiLiveTest {
+   public SecurityGroupApiLiveTest() {
+      prefix += "2";
+   }
+
+   private SecurityGroup group;
+   private boolean securityGroupsSupported;
+   private VirtualMachine vm;
+   private Zone zone;
+
+   @Test
+   public void testCreateDestroySecurityGroup() {
+      try {
+         zone = Iterables.find(client.getZoneApi().listZones(), new Predicate<Zone>() {
+
+            @Override
+            public boolean apply(Zone arg0) {
+               return arg0.isSecurityGroupsEnabled();
+            }
+
+         });
+         securityGroupsSupported = true;
+         for (SecurityGroup securityGroup : client.getSecurityGroupApi().listSecurityGroups(
+               ListSecurityGroupsOptions.Builder.named(prefix))) {
+            for (IngressRule rule : securityGroup.getIngressRules())
+               assertTrue(jobComplete.apply(client.getSecurityGroupApi().revokeIngressRule(rule.getId())), rule.toString());
+            client.getSecurityGroupApi().deleteSecurityGroup(securityGroup.getId());
+         }
+         group = client.getSecurityGroupApi().createSecurityGroup(prefix);
+         assertEquals(group.getName(), prefix);
+         checkGroup(group);
+         try {
+            client.getSecurityGroupApi().createSecurityGroup(prefix);
+            fail("Expected IllegalStateException");
+         } catch (IllegalStateException e) {
+
+         }
+      } catch (NoSuchElementException e) {
+         e.printStackTrace();
+      }
+   }
+
+   public static String getCurrentCIDR() throws IOException {
+      URL url = new URL("http://checkip.amazonaws.com/");
+      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+      connection.connect();
+      return Strings2.toStringAndClose(connection.getInputStream()).trim() + "/32";
+   }
+   
+   protected void skipIfSecurityGroupsNotSupported() {
+      if (!securityGroupsSupported) {
+         throw new SkipException("Test cannot run without security groups supported in a zone");
+      }
+   }
+   
+   @Test(dependsOnMethods = "testCreateDestroySecurityGroup")
+   public void testCreateIngress() throws Exception {
+      skipIfSecurityGroupsNotSupported();
+      String cidr = getCurrentCIDR();
+      ImmutableSet<String> cidrs = ImmutableSet.of(cidr);
+      assertTrue(jobComplete.apply(client.getSecurityGroupApi().authorizeIngressICMPToCIDRs(group.getId(), 0, 8, cidrs)), group.toString());
+      assertTrue(jobComplete.apply(client.getSecurityGroupApi().authorizeIngressPortsToCIDRs(group.getId(), "TCP", 22,
+            22, cidrs)), group.toString());
+
+      AccountInDomainOptions.Builder.accountInDomain(group.getAccount(), group.getDomainId());
+
+      // replace with get once bug is fixed where getGroup returns only one
+      // ingress rule
+      group = Iterables.find(client.getSecurityGroupApi().listSecurityGroups(), new Predicate<SecurityGroup>() {
+
+         @Override
+         public boolean apply(SecurityGroup input) {
+            return input.getId() == group.getId();
+         }
+
+      });
+
+      IngressRule ICMPPingRule = Iterables.find(group.getIngressRules(), new Predicate<IngressRule>() {
+
+         @Override
+         public boolean apply(IngressRule input) {
+            return "icmp".equals(input.getProtocol());
+         }
+
+      });
+
+      assert ICMPPingRule.getId() != null : ICMPPingRule;
+      assert "icmp".equals(ICMPPingRule.getProtocol()) : ICMPPingRule;
+      assert ICMPPingRule.getStartPort() == -1 : ICMPPingRule;
+      assert ICMPPingRule.getEndPort() == -1 : ICMPPingRule;
+      assert ICMPPingRule.getICMPCode() == 0 : ICMPPingRule;
+      assert ICMPPingRule.getICMPType() == 8 : ICMPPingRule;
+      assert ICMPPingRule.getAccount() == null : ICMPPingRule;
+      assert ICMPPingRule.getSecurityGroupName() == null : ICMPPingRule;
+      assert cidr.equals(ICMPPingRule.getCIDR()) : ICMPPingRule;
+
+      IngressRule SSHRule = Iterables.find(group.getIngressRules(), new Predicate<IngressRule>() {
+
+         @Override
+         public boolean apply(IngressRule input) {
+            return "tcp".equals(input.getProtocol());
+         }
+
+      });
+
+      assert SSHRule.getId() != null : SSHRule;
+      assert "tcp".equals(SSHRule.getProtocol()) : SSHRule;
+      assert SSHRule.getStartPort() == 22 : SSHRule;
+      assert SSHRule.getEndPort() == 22 : SSHRule;
+      assert SSHRule.getICMPCode() == -1 : SSHRule;
+      assert SSHRule.getICMPType() == -1 : SSHRule;
+      assert SSHRule.getAccount() == null : SSHRule;
+      assert SSHRule.getSecurityGroupName() == null : SSHRule;
+      assert cidr.equals(SSHRule.getCIDR()) : SSHRule;
+
+   }
+
+   public void testListSecurityGroup() throws Exception {
+      skipIfSecurityGroupsNotSupported();
+      for (SecurityGroup securityGroup : client.getSecurityGroupApi().listSecurityGroups())
+         checkGroup(securityGroup);
+   }
+
+   @Test(dependsOnMethods = "testCreateIngress")
+   public void testCreateVMInSecurityGroup() throws Exception {
+      skipIfSecurityGroupsNotSupported();
+      String defaultTemplate = template != null ? template.getImageId() : null;
+      vm = VirtualMachineApiLiveTest.createVirtualMachineWithSecurityGroupInZone(zone.getId(),
+            defaultTemplateOrPreferredInZone(defaultTemplate, client, zone.getId()), group.getId(), client,
+            jobComplete, virtualMachineRunning);
+      if (vm.getPassword() != null && loginCredentials.getOptionalPassword() == null)
+         loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build();
+      // ingress port 22
+      checkSSH(HostAndPort.fromParts(vm.getIPAddress(), 22));
+      // ingress icmp disabled as this is platform dependent and may actually
+      // just try tcp port 7
+      // assert InetAddress.getByName(vm.getIPAddress()).isReachable(1000) : vm;
+   }
+
+   protected void checkGroup(SecurityGroup group) {
+      // http://bugs.cloud.com/show_bug.cgi?id=8968
+      if (group.getIngressRules().size() <= 1) {
+         assertEquals(group, client.getSecurityGroupApi().getSecurityGroup(group.getId()));
+         assertEquals(group, client.getSecurityGroupApi().getSecurityGroupByName(group.getName()));
+      }
+      assert group.getId() != null : group;
+      assert group.getName() != null : group;
+      assert group.getAccount() != null : group;
+      assert group.getDomain() != null : group;
+      assert group.getDomainId() != null : group;
+      assert group.getIngressRules() != null : group;
+   }
+
+   @Test
+   public void testCreateVMWithoutSecurityGroupAssignsDefault() throws Exception {
+      skipIfSecurityGroupsNotSupported();
+      String defaultTemplate = template != null ? template.getImageId() : null;
+      VirtualMachine newVm = VirtualMachineApiLiveTest.createVirtualMachineWithOptionsInZone(DeployVirtualMachineOptions.NONE,
+            zone.getId(), defaultTemplateOrPreferredInZone(defaultTemplate, client, zone.getId()), client,
+            jobComplete, virtualMachineRunning);
+      try {
+         VirtualMachine runningVm = client.getVirtualMachineApi().getVirtualMachine(newVm.getId());
+         assertEquals(1, runningVm.getSecurityGroups().size());
+         assertEquals(Iterables.getOnlyElement(runningVm.getSecurityGroups()).getName(), "default");
+      } finally {
+         assertTrue(jobComplete.apply(client.getVirtualMachineApi().destroyVirtualMachine(newVm.getId())));
+      }
+   }
+
+   @AfterGroups(groups = "live")
+   @Override
+   protected void tearDownContext() {
+      if (vm != null) {
+         assertTrue(jobComplete.apply(client.getVirtualMachineApi().destroyVirtualMachine(vm.getId())));
+      }
+      if (group != null) {
+         for (IngressRule rule : group.getIngressRules())
+            assertTrue(jobComplete.apply(client.getSecurityGroupApi().revokeIngressRule(rule.getId())), rule.toString());
+         client.getSecurityGroupApi().deleteSecurityGroup(group.getId());
+         assertEquals(client.getSecurityGroupApi().getSecurityGroup(group.getId()), null);
+      }
+      super.tearDownContext();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiTest.java
new file mode 100644
index 0000000..b8dc540
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiTest.java
@@ -0,0 +1,299 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.cloudstack.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiTest;
+import org.jclouds.cloudstack.options.AccountInDomainOptions;
+import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.functions.IdentityFunction;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseFirstJsonValueNamed;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Functions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code SecurityGroupApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "SecurityGroupApiTest")
+public class SecurityGroupApiTest extends BaseCloudStackApiTest<SecurityGroupApi> {
+
+   public void testListSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "listSecurityGroups", ListSecurityGroupsOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&listAll=true HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testListSecurityGroupsOptions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "listSecurityGroups", ListSecurityGroupsOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListSecurityGroupsOptions.Builder.virtualMachineId("4")
+            .domainId("5").id("6")));
+
+      assertRequestLineEquals(
+            httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&listAll=true&virtualmachineid=4&domainid=5&id=6 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testGetSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "getSecurityGroup", String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&listAll=true&id=5 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest,
+            Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testGetSecurityGroupByName() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "getSecurityGroupByName", String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("some-name"));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&listAll=true&securitygroupname=some-name HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest,
+            Functions.compose(IdentityFunction.INSTANCE, IdentityFunction.INSTANCE).getClass());
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "createSecurityGroup", String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("goo"));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=createSecurityGroup&name=goo HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   HttpRequest authorizeSecurityGroupIngress3 = HttpRequest.builder().method("GET")
+                                                           .endpoint("http://localhost:8080/client/api")
+                                                           .addQueryParam("response", "json")
+                                                           .addQueryParam("command", "authorizeSecurityGroupIngress")
+                                                           .addQueryParam("securitygroupid", "2")
+                                                           .addQueryParam("protocol", "tcp")
+                                                           .addQueryParam("startport", "22")
+                                                           .addQueryParam("endport", "22")
+                                                           .addQueryParam("cidrlist", "1.1.1.1/24,1.2.2.2/16").build();
+
+   public void testAuthorizeIngressPortsToCIDRs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "authorizeIngressPortsToCIDRs", String.class,
+            String.class, int.class, int.class, Iterable.class, AccountInDomainOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "tcp", 22, 22,
+            ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16")));
+
+      assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress3.getRequestLine());
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   HttpRequest authorizeSecurityGroupIngress4 = HttpRequest.builder().method("GET")
+                                                           .endpoint("http://localhost:8080/client/api")
+                                                           .addQueryParam("response", "json")
+                                                           .addQueryParam("command", "authorizeSecurityGroupIngress")
+                                                           .addQueryParam("securitygroupid", "2")
+                                                           .addQueryParam("protocol", "tcp")
+                                                           .addQueryParam("startport", "22")
+                                                           .addQueryParam("endport", "22")
+                                                           .addQueryParam("usersecuritygrouplist%5B0%5D.account", "adrian")
+                                                           .addQueryParam("usersecuritygrouplist%5B0%5D.group", "group1")
+                                                           .addQueryParam("usersecuritygrouplist%5B1%5D.account", "adrian")
+                                                           .addQueryParam("usersecuritygrouplist%5B1%5D.group", "group2")
+                                                           .addQueryParam("usersecuritygrouplist%5B2%5D.account", "bob")
+                                                           .addQueryParam("usersecuritygrouplist%5B2%5D.group", "group1").build();
+
+   public void testAuthorizeIngressPortsToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "authorizeIngressPortsToSecurityGroups", String.class,
+            String.class, int.class, int.class, Multimap.class, AccountInDomainOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "tcp", 22, 22,
+            ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1")));
+
+      assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress4.getRequestLine());
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   HttpRequest authorizeSecurityGroupIngress1 = HttpRequest.builder().method("GET")
+                                                           .endpoint("http://localhost:8080/client/api")
+                                                           .addQueryParam("response", "json")
+                                                           .addQueryParam("command", "authorizeSecurityGroupIngress")
+                                                           .addQueryParam("protocol", "ICMP")
+                                                           .addQueryParam("securitygroupid", "2")
+                                                           .addQueryParam("icmpcode", "22")
+                                                           .addQueryParam("icmptype", "22")
+                                                           .addQueryParam("cidrlist", "1.1.1.1/24,1.2.2.2/16").build();
+
+   public void testAuthorizeIngressICMPToCIDRs() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "authorizeIngressICMPToCIDRs", String.class , int.class,
+            int.class, Iterable.class, AccountInDomainOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, 22, 22, ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16")));
+
+      assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress1.getRequestLine());
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   HttpRequest authorizeSecurityGroupIngress2 = HttpRequest.builder().method("GET")
+                                                           .endpoint("http://localhost:8080/client/api")
+                                                           .addQueryParam("response", "json")
+                                                           .addQueryParam("command", "authorizeSecurityGroupIngress")
+                                                           .addQueryParam("protocol", "ICMP")
+                                                           .addQueryParam("securitygroupid", "2")
+                                                           .addQueryParam("icmpcode", "22")
+                                                           .addQueryParam("icmptype", "22")
+                                                           .addQueryParam("usersecuritygrouplist%5B0%5D.account", "adrian")
+                                                           .addQueryParam("usersecuritygrouplist%5B0%5D.group", "group1")
+                                                           .addQueryParam("usersecuritygrouplist%5B1%5D.account", "adrian")
+                                                           .addQueryParam("usersecuritygrouplist%5B1%5D.group", "group2")
+                                                           .addQueryParam("usersecuritygrouplist%5B2%5D.account", "bob")
+                                                           .addQueryParam("usersecuritygrouplist%5B2%5D.group", "group1").build();
+
+   public void testAuthorizeIngressICMPToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "authorizeIngressICMPToSecurityGroups", String.class,
+            int.class, int.class, Multimap.class, AccountInDomainOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, 22, 22,
+            ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1")));
+
+      assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress2.getRequestLine());
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testRevokeIngressRule() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "revokeIngressRule", String.class,
+            AccountInDomainOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5,
+            AccountInDomainOptions.Builder.accountInDomain("adrian", "1")));
+
+      assertRequestLineEquals(
+            httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=revokeSecurityGroupIngress&id=5&account=adrian&domainid=1 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, "deleteSecurityGroup", String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=deleteSecurityGroup&id=5 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+}