You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/11/27 07:46:00 UTC

[51/79] stratos git commit: adding cloudstack dependancy

http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiExpectTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiExpectTest.java
new file mode 100644
index 0000000..46f20f9
--- /dev/null
+++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiExpectTest.java
@@ -0,0 +1,182 @@
+/*
+ * 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.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
+ */
+@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/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiLiveTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiLiveTest.java
new file mode 100644
index 0000000..df35d51
--- /dev/null
+++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiLiveTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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}
+ */
+@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/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiTest.java
new file mode 100644
index 0000000..b8492e1
--- /dev/null
+++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairApiTest.java
@@ -0,0 +1,135 @@
+/*
+ * 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}
+ */
+@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/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiLiveTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiLiveTest.java
new file mode 100644
index 0000000..a4bb788
--- /dev/null
+++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiLiveTest.java
@@ -0,0 +1,234 @@
+/*
+ * 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}
+ */
+@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().isPresent())
+         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/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiTest.java
new file mode 100644
index 0000000..1907877
--- /dev/null
+++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SecurityGroupApiTest.java
@@ -0,0 +1,297 @@
+/*
+ * 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}
+ */
+// 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, "Accept: application/json\n");
+      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/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SessionApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SessionApiExpectTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SessionApiExpectTest.java
new file mode 100644
index 0000000..a4cb945
--- /dev/null
+++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SessionApiExpectTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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 com.google.common.base.Charsets.UTF_8;
+import static com.google.common.hash.Hashing.md5;
+import static com.google.common.io.BaseEncoding.base16;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.cloudstack.CloudStackContext;
+import org.jclouds.cloudstack.domain.Account;
+import org.jclouds.cloudstack.domain.LoginResponse;
+import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+
+/**
+ * Tests behavior of {@code SessionApi}
+ */
+@Test(groups = "live", singleThreaded = true, testName = "SessionApiExpectTest")
+public class SessionApiExpectTest extends BaseCloudStackExpectTest<SessionApi> {
+
+   HttpRequest login = HttpRequest.builder().method("GET")
+                                  .endpoint("http://localhost:8080/client/api")
+                                  .addQueryParam("response", "json")
+                                  .addQueryParam("command", "login")
+                                  .addQueryParam("username", "jclouds")
+                                  .addQueryParam("domain", "Partners/jclouds")
+                                  .addQueryParam("password", "30e14b3727225d833aad2206acea1275")
+                                  .addHeader("Accept", "application/json").build();
+
+   public void testLoginWhenResponseIs2xxIncludesJSessionId() throws IOException {
+      String domain = "Partners/jclouds";
+      String user = "jclouds";
+      String password = "jcl0ud";
+      String md5password = base16().lowerCase().encode(md5().hashString(password, UTF_8).asBytes());
+
+      String jSessionId = "90DD65D13AEAA590ECCA312D150B9F6D";
+      SessionApi client = requestSendsResponse(login,
+         HttpResponse.builder()
+            .statusCode(200)
+            .headers(
+               ImmutableMultimap.<String, String>builder()
+                  .put("Set-Cookie", "JSESSIONID=" + jSessionId + "; Path=/client")
+                  .build())
+            .payload(payloadFromResource("/loginresponse.json"))
+            .build());
+
+      assertEquals(client.loginUserInDomainWithHashOfPassword(user, domain, md5password).toString(),
+         LoginResponse.builder().timeout(1800).lastName("Kiran").registered(false).username("jclouds").firstName("Vijay")
+            .domainId("11").accountType(Account.Type.DOMAIN_ADMIN).userId("19").sessionKey(
+            "uYT4/MNiglgAKiZRQkvV8QP8gn0=").jSessionId(jSessionId).accountName("jclouds").build().toString());
+   }
+
+   public void testLogout() throws IOException {
+      HttpRequest request = HttpRequest.builder()
+         .method("GET")
+         .endpoint(
+            URI.create("http://localhost:8080/client/api?response=json&command=logout&sessionkey=dummy-session-key"))
+         .build();
+
+      SessionApi client = requestSendsResponse(request,
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/logoutresponse.json"))
+            .build());
+
+      client.logoutUser("dummy-session-key");
+   }
+
+   @Override
+   protected SessionApi clientFrom(CloudStackContext context) {
+      return context.getApi().getSessionApi();
+   }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SessionApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SessionApiLiveTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SessionApiLiveTest.java
new file mode 100644
index 0000000..c5f3f9e
--- /dev/null
+++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SessionApiLiveTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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 com.google.common.base.Charsets.UTF_8;
+import static com.google.common.hash.Hashing.md5;
+import static com.google.common.io.BaseEncoding.base16;
+import static org.jclouds.cloudstack.features.GlobalAccountApiLiveTest.createTestAccount;
+import static org.jclouds.cloudstack.features.GlobalUserApiLiveTest.createTestUser;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.net.URI;
+
+import org.jclouds.cloudstack.domain.Account;
+import org.jclouds.cloudstack.domain.ApiKeyPair;
+import org.jclouds.cloudstack.domain.LoginResponse;
+import org.jclouds.cloudstack.domain.User;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest;
+import org.jclouds.cloudstack.util.ApiKeyPairs;
+import org.jclouds.rest.AuthorizationException;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code SessionApi}
+ */
+@Test(groups = "live", singleThreaded = true, testName = "SessionApiLiveTest")
+public class SessionApiLiveTest extends BaseCloudStackApiLiveTest {
+
+   @Test
+   public void testCreateContextUsingUserAndPasswordAuthentication() {
+      skipIfNotGlobalAdmin();
+
+      Account testAccount = null;
+      User testUser = null;
+
+      String prefix = this.prefix + "-session";
+      try {
+         testAccount = createTestAccount(globalAdminClient, prefix);
+         testUser = createTestUser(globalAdminClient, testAccount, prefix);
+
+         String expectedUsername = prefix + "-user";
+         assertEquals(testUser.getName(), expectedUsername);
+
+         checkLoginAsTheNewUser(expectedUsername);
+
+         ApiKeyPair expected = globalAdminClient.getUserClient().registerUserKeys(testUser.getId());
+         ApiKeyPair actual = ApiKeyPairs.loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
+            URI.create(endpoint), prefix + "-user", "password", "");
+
+         assertEquals(actual, expected);
+
+      } finally {
+         if (testUser != null)
+            globalAdminClient.getUserClient().deleteUser(testUser.getId());
+         if (testAccount != null)
+            globalAdminClient.getAccountApi().deleteAccount(testAccount.getId());
+      }
+   }
+
+   @Test(expectedExceptions = AuthorizationException.class)
+   public void testTryToGetApiKeypairWithWrongCredentials() {
+      ApiKeyPairs.loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
+         URI.create(endpoint), "dummy-missing-user", "with-a-wrong-password", "");
+   }
+
+   private void checkLoginAsTheNewUser(String expectedUsername) {
+      LoginResponse response = globalAdminClient.getSessionApi().loginUserInDomainWithHashOfPassword(
+            expectedUsername, "", base16().lowerCase().encode(md5().hashString("password", UTF_8).asBytes()));
+
+      assertNotNull(response);
+      assertNotNull(response.getSessionKey());
+      assertNotNull(response.getJSessionId());
+
+      client.getSessionApi().logoutUser(response.getSessionKey());
+   }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SnapshotApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SnapshotApiLiveTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SnapshotApiLiveTest.java
new file mode 100644
index 0000000..91801d6
--- /dev/null
+++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SnapshotApiLiveTest.java
@@ -0,0 +1,141 @@
+/*
+ * 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 com.google.common.collect.Iterables.find;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertNotSame;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertTrue;
+
+import java.util.Set;
+
+import javax.annotation.Resource;
+
+import org.jclouds.cloudstack.domain.AsyncCreateResponse;
+import org.jclouds.cloudstack.domain.Snapshot;
+import org.jclouds.cloudstack.domain.Volume;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest;
+import org.jclouds.cloudstack.options.ListSnapshotsOptions;
+import org.jclouds.logging.Logger;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of {@code SnapshotApi}
+ */
+@Test(groups = "live", singleThreaded = true, testName = "SnapshotApiLiveTest")
+public class SnapshotApiLiveTest extends BaseCloudStackApiLiveTest {
+
+   @Resource Logger logger = Logger.NULL;
+   
+   public void testListSnapshots() {
+      Set<Snapshot> snapshots = client.getSnapshotApi().listSnapshots();
+      assertNotNull(snapshots);
+      assertFalse(snapshots.isEmpty());
+
+      for (Snapshot snapshot : snapshots) {
+         checkSnapshot(snapshot);
+      }
+   }
+
+   public void testListSnapshotsById() {
+      Iterable<String> snapshotIds = Iterables.transform(client.getSnapshotApi().listSnapshots(), new Function<Snapshot, String>() {
+          public String apply(Snapshot input) {
+              return input.getId();
+          }
+      });
+      assertNotNull(snapshotIds);
+      assertFalse(Iterables.isEmpty(snapshotIds));
+
+      for (String id : snapshotIds) {
+         Set<Snapshot> found = client.getSnapshotApi().listSnapshots(ListSnapshotsOptions.Builder.id(id));
+         assertNotNull(found);
+         assertEquals(1, found.size());
+         Snapshot snapshot = Iterables.getOnlyElement(found);
+         assertEquals(id, snapshot.getId());
+         checkSnapshot(snapshot);
+      }
+   }
+
+   public void testListSnapshotsNonexistantId() {
+      Set<Snapshot> found = client.getSnapshotApi().listSnapshots(ListSnapshotsOptions.Builder.id("foo"));
+      assertNotNull(found);
+      assertTrue(found.isEmpty());
+   }
+
+   public void testGetSnapshotById() {
+      Iterable<String> snapshotIds = Iterables.transform(client.getSnapshotApi().listSnapshots(), new Function<Snapshot, String>() {
+          public String apply(Snapshot input) {
+              return input.getId();
+          }
+      });
+      assertNotNull(snapshotIds);
+      assertFalse(Iterables.isEmpty(snapshotIds));
+
+      for (String id : snapshotIds) {
+         Snapshot found = client.getSnapshotApi().getSnapshot(id);
+         assertNotNull(found);
+         assertEquals(id, found.getId());
+         checkSnapshot(found);
+      }
+   }
+
+   public void testGetSnapshotNonexistantId() {
+      Snapshot found = client.getSnapshotApi().getSnapshot("foo");
+      assertNull(found);
+   }
+
+   protected Volume getPreferredVolume() {
+      for (Volume candidate : client.getVolumeApi().listVolumes()) {
+         if (candidate.getState() == Volume.State.READY)
+            return candidate;
+      }
+      throw new AssertionError("No suitable Volume found.");
+   }
+
+   public void testCreateSnapshotFromVolume() {
+      final Volume volume = getPreferredVolume();  //fail fast if none
+      logger.info("creating snapshot from volume %s", volume);
+      AsyncCreateResponse job = client.getSnapshotApi().createSnapshot(volume.getId());
+      assertTrue(jobComplete.apply(job.getJobId()));
+      Snapshot snapshot = findSnapshotWithId(job.getId());
+      logger.info("created snapshot %s from volume %s", snapshot, volume);
+      checkSnapshot(snapshot);
+      client.getSnapshotApi().deleteSnapshot(snapshot.getId());
+   }
+
+   private void checkSnapshot(final Snapshot snapshot) {
+      assertNotNull(snapshot.getId());
+      assertNotNull(snapshot.getName());
+      assertNotSame(Snapshot.Type.UNRECOGNIZED, snapshot.getSnapshotType());
+   }
+
+   private Snapshot findSnapshotWithId(final String id) {
+      return find(client.getSnapshotApi().listSnapshots(), new Predicate<Snapshot>() {
+         @Override
+         public boolean apply(Snapshot arg0) {
+            return arg0.getId().equals(id);
+         }
+      });
+   }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SnapshotApiTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SnapshotApiTest.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SnapshotApiTest.java
new file mode 100644
index 0000000..897bf3c
--- /dev/null
+++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/test/java/org/jclouds/cloudstack/features/SnapshotApiTest.java
@@ -0,0 +1,240 @@
+/*
+ * 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 org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.cloudstack.domain.Snapshot;
+import org.jclouds.cloudstack.domain.SnapshotPolicySchedule;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiTest;
+import org.jclouds.cloudstack.options.CreateSnapshotOptions;
+import org.jclouds.cloudstack.options.ListSnapshotPoliciesOptions;
+import org.jclouds.cloudstack.options.ListSnapshotsOptions;
+import org.jclouds.cloudstack.util.SnapshotPolicySchedules;
+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.http.functions.UnwrapOnlyJsonValue;
+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.ImmutableSet;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests the behaviour of SnapshotApi.
+ * 
+ * @see SnapshotApi
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "SnapshotApiTest")
+public class SnapshotApiTest extends BaseCloudStackApiTest<SnapshotApi> {
+
+   public void testCreateSnapshot() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "createSnapshot", String.class, CreateSnapshotOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=createSnapshot&volumeid=5 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      checkFilters(httpRequest);
+   }
+
+   public void testCreateSnapshotOptions() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "createSnapshot", String.class, CreateSnapshotOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5, CreateSnapshotOptions.Builder.accountInDomain("acc", "7").policyId("9")));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=createSnapshot&volumeid=5&account=acc&domainid=7&policyid=9 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      checkFilters(httpRequest);
+   }
+
+   public void testListSnapshots() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "listSnapshots", ListSnapshotsOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSnapshots&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 testGetSnapshot() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "getSnapshot", String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSnapshots&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 testListSnapshotsOptions() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "listSnapshots", ListSnapshotsOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListSnapshotsOptions.Builder.accountInDomain("acc", "7").id("5").interval(Snapshot.Interval.MONTHLY).isRecursive(true).keyword("fred").name("fred's snapshot").snapshotType(Snapshot.Type.RECURRING).volumeId("11")));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSnapshots&listAll=true&account=acc&domainid=7&id=5&intervaltype=MONTHLY&isrecursive=true&keyword=fred&name=fred%27s%20snapshot&snapshottype=RECURRING&volumeid=11 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 testDeleteSnapshot() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "deleteSnapshot", String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(14));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=deleteSnapshot&id=14 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+   }
+
+   HttpRequest extractIso = HttpRequest.builder().method("GET")
+                                       .endpoint("http://localhost:8080/client/api")
+                                       .addQueryParam("response", "json")
+                                       .addQueryParam("command", "createSnapshotPolicy")
+                                       .addQueryParam("maxsnaps", "10")
+                                       .addQueryParam("timezone", "UTC")
+                                       .addQueryParam("volumeid", "12")
+                                       .addQueryParam("intervaltype", "MONTHLY")
+                                       .addQueryParam("schedule", "07%3A06%3A05").build();
+
+   public void testCreateSnapshotPolicy() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "createSnapshotPolicy", SnapshotPolicySchedule.class, String.class, String.class, String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(SnapshotPolicySchedules.monthly(5, 6, 7), 10, "UTC", 12));
+
+      assertRequestLineEquals(httpRequest, extractIso.getRequestLine());
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      checkFilters(httpRequest);
+   }
+
+   public void testDeleteSnapshotPolicy() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "deleteSnapshotPolicy", String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(7));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=deleteSnapshotPolicies&id=7 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+   }
+
+   public void testDeleteSnapshotPolicies() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "deleteSnapshotPolicies", Iterable.class);
+      Iterable<String> ids = ImmutableSet.of("3", "5", "7");
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ids));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=deleteSnapshotPolicies&ids=3,5,7 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+   }
+
+   public void testListSnapshotPolicies() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(10));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSnapshotPolicies&listAll=true&volumeid=10 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+   }
+
+   public void testListSnapshotPoliciesOptions() throws NoSuchMethodException {
+      Invokable<?, ?> method = method(SnapshotApi.class, "listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(10, ListSnapshotPoliciesOptions.Builder.accountInDomain("fred", "4").keyword("bob")));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listSnapshotPolicies&listAll=true&volumeid=10&account=fred&domainid=4&keyword=bob HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+   }
+}