You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2016/08/08 07:18:58 UTC
jclouds-labs git commit: JCLOUDS-1149 oneandone-firewallpolicies-api
Repository: jclouds-labs
Updated Branches:
refs/heads/master d0b07a668 -> 50744595d
JCLOUDS-1149 oneandone-firewallpolicies-api
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/50744595
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/50744595
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/50744595
Branch: refs/heads/master
Commit: 50744595dd89b0cad1d3c5416b60a0520e2dc5e0
Parents: d0b07a6
Author: Ali Bazlamit <al...@hotmail.com>
Authored: Fri Aug 5 17:41:32 2016 +0300
Committer: Ignasi Barrera <na...@apache.org>
Committed: Mon Aug 8 09:04:34 2016 +0200
----------------------------------------------------------------------
.../jclouds/oneandone/rest/OneAndOneApi.java | 4 +
.../oneandone/rest/domain/FirewallPolicy.java | 190 +++++++++++
.../jclouds/oneandone/rest/domain/Types.java | 14 +
.../rest/features/FirewallPolicyApi.java | 123 +++++++
.../features/FirewallPolicyApiLiveTest.java | 191 +++++++++++
.../features/FirewallPolicyApiMockTest.java | 335 +++++++++++++++++++
.../rest/internal/BaseOneAndOneApiMockTest.java | 1 -
.../rest/internal/BaseOneAndOneLiveTest.java | 6 +
.../test/resources/firewallpolicies/get.json | 26 ++
.../resources/firewallpolicies/get.rule.json | 7 +
.../firewallpolicies/get.serverip.json | 5 +
.../test/resources/firewallpolicies/list.json | 54 +++
.../firewallpolicies/list.options.json | 54 +++
.../resources/firewallpolicies/list.rules.json | 16 +
.../firewallpolicies/list.serverips.json | 7 +
.../src/test/resources/sharedStorage/get.json | 24 ++
.../resources/sharedStorage/list.access.json | 24 ++
.../src/test/resources/sharedStorage/list.json | 62 ++++
.../resources/sharedStorage/list.options.json | 62 ++++
.../resources/sharedStorage/server.get.json | 5 +
.../resources/sharedStorage/servers.list.json | 12 +
21 files changed, 1221 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApi.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApi.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApi.java
index be5f0d9..b4f464a 100644
--- a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApi.java
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApi.java
@@ -17,6 +17,7 @@
package org.apache.jclouds.oneandone.rest;
import java.io.Closeable;
+import org.apache.jclouds.oneandone.rest.features.FirewallPolicyApi;
import org.apache.jclouds.oneandone.rest.features.ImageApi;
import org.apache.jclouds.oneandone.rest.features.ServerApi;
import org.apache.jclouds.oneandone.rest.features.SharedStorageApi;
@@ -32,4 +33,7 @@ public interface OneAndOneApi extends Closeable {
@Delegate
SharedStorageApi sharedStorageApi();
+
+ @Delegate
+ FirewallPolicyApi firewallPolicyApi();
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/FirewallPolicy.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/FirewallPolicy.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/FirewallPolicy.java
new file mode 100644
index 0000000..a54b653
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/FirewallPolicy.java
@@ -0,0 +1,190 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.Types.RuleProtocol;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class FirewallPolicy {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ @Nullable
+ public abstract String description();
+
+ @Nullable
+ public abstract String state();
+
+ @Nullable
+ public abstract String creationDate();
+
+ @Nullable
+ public abstract String defaultState();
+
+ public abstract List<Rule> rules();
+
+ public abstract List<ServerIp> serverIps();
+
+ @Nullable
+ public abstract String cloudpanelId();
+
+ @SerializedNames({"id", "name", "description", "state", "creation_date", "default", "rules", "server_ips", "cloudpanel_id"})
+ public static FirewallPolicy create(String id, String name, String description, String state, String creationDate, String defaultState, List<Rule> rules, List<ServerIp> serverIps, String cloudpanelId) {
+ return new AutoValue_FirewallPolicy(id, name, description, state, creationDate, defaultState, rules == null ? ImmutableList.<Rule>of() : ImmutableList.copyOf(rules), serverIps == null ? ImmutableList.<ServerIp>of() : ImmutableList.copyOf(serverIps), cloudpanelId);
+ }
+
+ @AutoValue
+ public abstract static class CreateFirewallPolicy {
+
+ public abstract String name();
+
+ @Nullable
+ public abstract String description();
+
+ public abstract List<Rule.CreatePayload> rules();
+
+ @SerializedNames({"name", "description", "rules"})
+ public static CreateFirewallPolicy create(final String name, final String description, List<Rule.CreatePayload> rules) {
+ return new AutoValue_FirewallPolicy_CreateFirewallPolicy(name, description, rules == null ? ImmutableList.<Rule.CreatePayload>of() : ImmutableList.copyOf(rules));
+ }
+ }
+
+ @AutoValue
+ public abstract static class UpdateFirewallPolicy {
+
+ @Nullable
+ public abstract String name();
+
+ @Nullable
+ public abstract String description();
+
+ @SerializedNames({"name", "description"})
+ public static UpdateFirewallPolicy create(final String name, final String description) {
+ return new AutoValue_FirewallPolicy_UpdateFirewallPolicy(name, description);
+ }
+ }
+
+ @AutoValue
+ public abstract static class ServerIp {
+
+ public abstract String id();
+
+ public abstract String ip();
+
+ public abstract String serverName();
+
+ @SerializedNames({"id", "ip", "server_name"})
+ public static ServerIp create(String id, String ip, String serverName) {
+ return new AutoValue_FirewallPolicy_ServerIp(id, ip, serverName);
+ }
+
+ @AutoValue
+ public abstract static class CreateServerIp {
+
+ public abstract List<String> serverIps();
+
+ @SerializedNames({"server_ips"})
+ public static CreateServerIp create(final List<String> serverIps) {
+ return new AutoValue_FirewallPolicy_ServerIp_CreateServerIp(serverIps == null ? ImmutableList.<String>of() : ImmutableList.copyOf(serverIps));
+ }
+ }
+ }
+
+ @AutoValue
+ public abstract static class Rule {
+
+ public abstract String id();
+
+ @Nullable
+ public abstract RuleProtocol protocol();
+
+ @Nullable
+ public abstract Integer portFrom();
+
+ @Nullable
+ public abstract Integer portTo();
+
+ @Nullable
+ public abstract String source();
+
+ @SerializedNames({"id", "protocol", "port_from", "port_to", "source"})
+ public static Rule create(String id, RuleProtocol protocol, Integer portFrom, Integer portTo, String source) {
+ return new AutoValue_FirewallPolicy_Rule(id, protocol, portFrom, portTo, source);
+ }
+
+ @AutoValue
+ public abstract static class CreatePayload {
+
+ public abstract RuleProtocol protocol();
+
+ @Nullable
+ public abstract Integer portFrom();
+
+ @Nullable
+ public abstract Integer portTo();
+
+ @Nullable
+ public abstract String source();
+
+ @SerializedNames({"protocol", "port_from", "port_to", "source"})
+ public static CreatePayload create(RuleProtocol protocol, Integer portFrom, Integer portTo, String source) {
+ return builder()
+ .portFrom(portFrom)
+ .portTo(portTo)
+ .protocol(protocol)
+ .source(source)
+ .build();
+ }
+
+ public static Builder builder() {
+ return new AutoValue_FirewallPolicy_Rule_CreatePayload.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder protocol(RuleProtocol protocol);
+
+ public abstract Builder portFrom(Integer portFrom);
+
+ public abstract Builder portTo(Integer portTo);
+
+ public abstract Builder source(String source);
+
+ public abstract CreatePayload build();
+ }
+ }
+
+ @AutoValue
+ public abstract static class AddRule {
+
+ public abstract List<CreatePayload> rules();
+
+ @SerializedNames({"rules"})
+ public static AddRule create(List<CreatePayload> rules) {
+ return new AutoValue_FirewallPolicy_Rule_AddRule(rules == null ? ImmutableList.<CreatePayload>of() : ImmutableList.copyOf(rules));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Types.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Types.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Types.java
index a69a599..12bcb25 100644
--- a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Types.java
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Types.java
@@ -147,4 +147,18 @@ public class Types {
return Enums.getIfPresent(StorageServerRights.class, v).or(UNRECOGNIZED);
}
}
+
+ public enum RuleProtocol {
+ TCP,
+ UDP,
+ ICMP,
+ AH,
+ ESP,
+ GRE,
+ UNRECOGNIZED;
+
+ public static RuleProtocol fromValue(String v) {
+ return Enums.getIfPresent(RuleProtocol.class, v).or(UNRECOGNIZED);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApi.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApi.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApi.java
new file mode 100644
index 0000000..a8244ef
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApi.java
@@ -0,0 +1,123 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.features;
+
+import java.io.Closeable;
+import java.util.List;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.apache.jclouds.oneandone.rest.domain.FirewallPolicy;
+import org.apache.jclouds.oneandone.rest.domain.options.GenericQueryOptions;
+import org.apache.jclouds.oneandone.rest.filters.AuthenticateRequest;
+import org.jclouds.Fallbacks;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+@Path("/firewall_policies")
+@Produces("application/json")
+@Consumes("application/json")
+@RequestFilters(AuthenticateRequest.class)
+public interface FirewallPolicyApi extends Closeable {
+
+ @Named("firewallpolicies:list")
+ @GET
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<FirewallPolicy> list();
+
+ @Named("firewallpolicies:list")
+ @GET
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<FirewallPolicy> list(GenericQueryOptions options);
+
+ @Named("firewallpolicies:get")
+ @GET
+ @Path("/{firewallPolicyId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ FirewallPolicy get(@PathParam("firewallPolicyId") String firewallPolicyId);
+
+ @Named("firewallpolicies:create")
+ @POST
+ FirewallPolicy create(@BinderParam(BindToJsonPayload.class) FirewallPolicy.CreateFirewallPolicy firewallPolicy);
+
+ @Named("firewallpolicies:update")
+ @PUT
+ @Path("/{firewallPolicyId}")
+ FirewallPolicy update(@PathParam("firewallPolicyId") String firewallPolicyId, @BinderParam(BindToJsonPayload.class) FirewallPolicy.UpdateFirewallPolicy firewallPolicy);
+
+ @Named("firewallpolicies:delete")
+ @DELETE
+ @Path("/{firewallPolicyId}")
+ @MapBinder(BindToJsonPayload.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ FirewallPolicy delete(@PathParam("firewallPolicyId") String firewallPolicyId);
+
+ @Named("firewallpolicies:serverips:list")
+ @GET
+ @Path("/{firewallPolicyId}/server_ips")
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<FirewallPolicy.ServerIp> listServerIps(@PathParam("firewallPolicyId") String firewallPolicyId);
+
+ @Named("firewallpolicies:serverips:create")
+ @POST
+ @Path("/{firewallPolicyId}/server_ips")
+ FirewallPolicy assignServerIp(@PathParam("firewallPolicyId") String firewallPolicyId, @BinderParam(BindToJsonPayload.class) FirewallPolicy.ServerIp.CreateServerIp serverIp);
+
+ @Named("firewallpolicies:serverips:get")
+ @GET
+ @Path("/{firewallPolicyId}/server_ips/{serverIpId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ FirewallPolicy.ServerIp getServerIp(@PathParam("firewallPolicyId") String firewallPolicyId, @PathParam("serverIpId") String serverIpId);
+
+ @Named("firewallpolicies:serverips:delete")
+ @DELETE
+ @Path("/{firewallPolicyId}/server_ips/{serverIpId}")
+ @MapBinder(BindToJsonPayload.class)
+ FirewallPolicy unassignServerIp(@PathParam("firewallPolicyId") String firewallPolicyId, @PathParam("serverIpId") String serverIpId);
+
+ @Named("firewallpolicies:rules:list")
+ @GET
+ @Path("/{firewallPolicyId}/rules")
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<FirewallPolicy.Rule> listRules(@PathParam("firewallPolicyId") String firewallPolicyId);
+
+ @Named("firewallpolicies:rules:create")
+ @POST
+ @Path("/{firewallPolicyId}/rules")
+ FirewallPolicy addRules(@PathParam("firewallPolicyId") String firewallPolicyId, @BinderParam(BindToJsonPayload.class) FirewallPolicy.Rule.AddRule rule);
+
+ @Named("firewallpolicies:rules:get")
+ @GET
+ @Path("/{firewallPolicyId}/rules/{ruleId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ FirewallPolicy.Rule getRule(@PathParam("firewallPolicyId") String firewallPolicyId, @PathParam("ruleId") String ruleId);
+
+ @Named("firewallpolicies:rules:delete")
+ @DELETE
+ @Path("/{firewallPolicyId}/rules/{ruleId}")
+ @MapBinder(BindToJsonPayload.class)
+ FirewallPolicy removeRule(@PathParam("firewallPolicyId") String firewallPolicyId, @PathParam("ruleId") String ruleId);
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApiLiveTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApiLiveTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApiLiveTest.java
new file mode 100644
index 0000000..2b139d0
--- /dev/null
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApiLiveTest.java
@@ -0,0 +1,191 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.features;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.FirewallPolicy;
+import org.apache.jclouds.oneandone.rest.domain.Server;
+import org.apache.jclouds.oneandone.rest.domain.Types;
+import org.apache.jclouds.oneandone.rest.domain.options.GenericQueryOptions;
+import org.apache.jclouds.oneandone.rest.internal.BaseOneAndOneLiveTest;
+import org.testng.Assert;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+@Test(groups = "live", testName = "FirewallPolicyApiLiveTest")
+public class FirewallPolicyApiLiveTest extends BaseOneAndOneLiveTest {
+
+ private FirewallPolicy currentFirewallPolicy;
+ private Server currentServer;
+ private List<FirewallPolicy> firewallPolicies;
+
+ private FirewallPolicyApi firewallPolicyApi() {
+ return api.firewallPolicyApi();
+ }
+
+ @BeforeClass
+ public void setupTest() {
+ currentServer = createServer("firewallpolicies jclouds server");
+ assertNodeAvailable(currentServer);
+
+ List<FirewallPolicy.Rule.CreatePayload> rules = new ArrayList<FirewallPolicy.Rule.CreatePayload>();
+ FirewallPolicy.Rule.CreatePayload rule = FirewallPolicy.Rule.CreatePayload.builder()
+ .portFrom(80)
+ .portTo(80)
+ .protocol(Types.RuleProtocol.TCP)
+ .source("0.0.0.0")
+ .build();
+ rules.add(rule);
+ currentFirewallPolicy = firewallPolicyApi().create(FirewallPolicy.CreateFirewallPolicy.create("jclouds firewall policy", "desc", rules));
+ }
+
+ @Test
+ public void testList() {
+ firewallPolicies = firewallPolicyApi().list();
+
+ assertNotNull(firewallPolicies);
+ assertFalse(firewallPolicies.isEmpty());
+ Assert.assertTrue(firewallPolicies.size() > 0);
+ }
+
+ @Test
+ public void testListWithOption() {
+ GenericQueryOptions options = new GenericQueryOptions();
+ options.options(0, 0, null, "jclouds", null);
+ List<FirewallPolicy> imageWithQuery = firewallPolicyApi().list(options);
+
+ assertNotNull(imageWithQuery);
+ assertFalse(imageWithQuery.isEmpty());
+ Assert.assertTrue(imageWithQuery.size() > 0);
+ }
+
+ @Test
+ public void testGet() {
+ FirewallPolicy result = firewallPolicyApi().get(currentFirewallPolicy.id());
+
+ assertNotNull(result);
+ assertEquals(result.id(), currentFirewallPolicy.id());
+ }
+
+ @Test
+ public void testUpdate() {
+ String updatedName = "UpdatedjcloudsPolicy";
+
+ FirewallPolicy updateResult = firewallPolicyApi().update(currentFirewallPolicy.id(), FirewallPolicy.UpdateFirewallPolicy.create(updatedName, null));
+
+ assertNotNull(updateResult);
+ assertEquals(updateResult.name(), updatedName);
+ }
+
+ @Test(dependsOnMethods = "testUpdate")
+ public void testAssignServerIp() {
+ assertNodeAvailable(currentServer);
+ currentServer = updateServerStatus(currentServer);
+ List<String> ips = new ArrayList<String>();
+ ips.add(currentServer.ips().get(0).id());
+ FirewallPolicy.ServerIp.CreateServerIp toAdd = FirewallPolicy.ServerIp.CreateServerIp.create(ips);
+
+ FirewallPolicy updateResult = firewallPolicyApi().assignServerIp(currentFirewallPolicy.id(), toAdd);
+ assertEquals(updateResult.serverIps().get(0).id(), currentServer.ips().get(0).id());
+
+ assertNotNull(updateResult);
+
+ }
+
+ @Test(dependsOnMethods = "testAssignServerIp")
+ public void testListServerIps() {
+ List<FirewallPolicy.ServerIp> servers = firewallPolicyApi().listServerIps(currentFirewallPolicy.id());
+
+ assertNotNull(servers);
+ assertFalse(servers.isEmpty());
+ Assert.assertTrue(servers.size() > 0);
+ }
+
+ @Test(dependsOnMethods = "testListServerIps")
+ public void testServerIpGet() {
+ FirewallPolicy.ServerIp result = firewallPolicyApi().getServerIp(currentFirewallPolicy.id(), currentServer.ips().get(0).id());
+
+ assertNotNull(result);
+ }
+
+ @Test(dependsOnMethods = "testServerIpGet")
+ public void testUnassignServer() {
+ FirewallPolicy result = firewallPolicyApi().unassignServerIp(currentFirewallPolicy.id(), currentServer.ips().get(0).id());
+
+ assertNotNull(result);
+ assertEquals(result.serverIps().size(), 0);
+ }
+
+ @Test(dependsOnMethods = "testUnassignServer")
+ public void testAddRules() {
+ assertNodeAvailable(currentServer);
+ currentServer = updateServerStatus(currentServer);
+ List<FirewallPolicy.Rule.CreatePayload> rules = new ArrayList<FirewallPolicy.Rule.CreatePayload>();
+ FirewallPolicy.Rule.CreatePayload rule = FirewallPolicy.Rule.CreatePayload.builder()
+ .portFrom(4567)
+ .portTo(4567)
+ .protocol(Types.RuleProtocol.TCP)
+ .source("0.0.0.0")
+ .build();
+ rules.add(rule);
+ FirewallPolicy response = firewallPolicyApi().addRules(currentFirewallPolicy.id(), FirewallPolicy.Rule.AddRule.create(rules));
+ FirewallPolicy.Rule ruleFromApi = firewallPolicyApi().getRule(currentFirewallPolicy.id(), currentFirewallPolicy.rules().get(0).id());
+
+ assertNotNull(response);
+ assertNotNull(ruleFromApi);
+
+ }
+
+ @Test(dependsOnMethods = "testAddRules")
+ public void testListRules() {
+ List<FirewallPolicy.Rule> servers = firewallPolicyApi().listRules(currentFirewallPolicy.id());
+
+ assertNotNull(servers);
+ assertFalse(servers.isEmpty());
+ Assert.assertTrue(servers.size() > 0);
+ }
+
+ @Test(dependsOnMethods = "testAddRules")
+ public void testGetRule() {
+ FirewallPolicy.Rule result = firewallPolicyApi().getRule(currentFirewallPolicy.id(), currentFirewallPolicy.rules().get(0).id());
+
+ assertNotNull(result);
+ }
+
+ @Test(dependsOnMethods = "testGetRule")
+ public void testRemoveRule() {
+ FirewallPolicy result = firewallPolicyApi().removeRule(currentFirewallPolicy.id(), currentFirewallPolicy.rules().get(0).id());
+ FirewallPolicy.Rule ruleFromApi = firewallPolicyApi().getRule(currentFirewallPolicy.id(), currentFirewallPolicy.rules().get(0).id());
+
+ assertNotNull(result);
+ assertEquals(ruleFromApi, null);
+ assertEquals(result.id(), currentFirewallPolicy.id());
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void teardownTest() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ firewallPolicyApi().delete(currentFirewallPolicy.id());
+ assertNodeAvailable(currentServer);
+ deleteServer(currentServer.id());
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApiMockTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApiMockTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApiMockTest.java
new file mode 100644
index 0000000..29aa1b8
--- /dev/null
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/FirewallPolicyApiMockTest.java
@@ -0,0 +1,335 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.features;
+
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.FirewallPolicy;
+import org.apache.jclouds.oneandone.rest.domain.Types;
+import org.apache.jclouds.oneandone.rest.domain.options.GenericQueryOptions;
+import org.apache.jclouds.oneandone.rest.internal.BaseOneAndOneApiMockTest;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "FirewallPolicyApiMockTest", singleThreaded = true)
+public class FirewallPolicyApiMockTest extends BaseOneAndOneApiMockTest {
+
+ private FirewallPolicyApi firewallpolicyApi() {
+ return api.firewallPolicyApi();
+ }
+
+ @Test
+ public void testList() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/list.json"))
+ );
+
+ List<FirewallPolicy> policies = firewallpolicyApi().list();
+
+ assertNotNull(policies);
+ assertEquals(policies.size(), 2);
+
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies");
+ }
+
+ @Test
+ public void testList404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404));
+
+ List<FirewallPolicy> firewallpolicies = firewallpolicyApi().list();
+
+ assertEquals(firewallpolicies.size(), 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies");
+ }
+
+ @Test
+ public void testListWithOption() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/list.options.json"))
+ );
+ GenericQueryOptions options = new GenericQueryOptions();
+ options.options(0, 0, null, "New", null);
+ List<FirewallPolicy> firewallpolicies = firewallpolicyApi().list(options);
+
+ assertNotNull(firewallpolicies);
+ assertEquals(firewallpolicies.size(), 2);
+
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies?q=New");
+ }
+
+ @Test
+ public void testListWithOption404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ GenericQueryOptions options = new GenericQueryOptions();
+ options.options(0, 0, null, "test", null);
+ List<FirewallPolicy> firewallpolicies = firewallpolicyApi().list(options);
+
+ assertEquals(firewallpolicies.size(), 0);
+
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies?q=test");
+ }
+
+ public void testGet() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/get.json"))
+ );
+ FirewallPolicy result = firewallpolicyApi().get("firewallpolicyId");
+
+ assertNotNull(result);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies/firewallpolicyId");
+ }
+
+ @Test
+ public void testGet404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ FirewallPolicy result = firewallpolicyApi().get("firewallpolicyId");
+
+ assertEquals(result, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies/firewallpolicyId");
+ }
+
+ @Test
+ public void testCreate() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/get.json"))
+ );
+ List<FirewallPolicy.Rule.CreatePayload> rules = new ArrayList<FirewallPolicy.Rule.CreatePayload>();
+ FirewallPolicy.Rule.CreatePayload rule = FirewallPolicy.Rule.CreatePayload.builder()
+ .portFrom(80)
+ .portTo(80)
+ .protocol(Types.RuleProtocol.TCP)
+ .source("source")
+ .build();
+ rules.add(rule);
+ FirewallPolicy response = firewallpolicyApi().create(FirewallPolicy.CreateFirewallPolicy.create("name", "desc", rules));
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/firewall_policies", "{\"name\":\"name\",\"description\":\"desc\",\"rules\":[{\"protocol\":\"TCP\",\"port_from\":80,\"port_to\":80,\"source\":\"source\"}]}");
+ }
+
+ @Test
+ public void testUpdate() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/get.json"))
+ );
+ FirewallPolicy response = firewallpolicyApi().update("firewallpolicyId", FirewallPolicy.UpdateFirewallPolicy.create("name", "desc"));
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "PUT", "/firewall_policies/firewallpolicyId", "{\"name\":\"name\",\"description\":\"desc\"}");
+ }
+
+ @Test
+ public void testDelete() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/get.json"))
+ );
+ FirewallPolicy response = firewallpolicyApi().delete("firewallpolicyId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/firewall_policies/firewallpolicyId");
+ }
+
+ @Test
+ public void testDelete404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404));
+ FirewallPolicy response = firewallpolicyApi().delete("firewallpolicyId");
+
+ assertEquals(response, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/firewall_policies/firewallpolicyId");
+ }
+
+ @Test
+ public void testListServerIps() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/list.serverips.json"))
+ );
+
+ List<FirewallPolicy.ServerIp> serverIps = firewallpolicyApi().listServerIps("firewallpolicyId");
+
+ assertNotNull(serverIps);
+ assertEquals(serverIps.size(), 1);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies/firewallpolicyId/server_ips");
+ }
+
+ @Test
+ public void testListServerIps404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+
+ List<FirewallPolicy.ServerIp> serverIps = firewallpolicyApi().listServerIps("firewallpolicyId");
+
+ assertEquals(serverIps.size(), 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies/firewallpolicyId/server_ips");
+ }
+
+ @Test
+ public void testGetServerIp() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/get.serverip.json"))
+ );
+ FirewallPolicy.ServerIp result = firewallpolicyApi().getServerIp("firewallpolicyId", "serverIpId");
+
+ assertNotNull(result);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies/firewallpolicyId/server_ips/serverIpId");
+ }
+
+ @Test
+ public void testGetServerIp404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ FirewallPolicy.ServerIp result = firewallpolicyApi().getServerIp("firewallpolicyId", "serverIpId");
+
+ assertEquals(result, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies/firewallpolicyId/server_ips/serverIpId");
+ }
+
+ @Test
+ public void testAssignServerIp() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/get.json"))
+ );
+
+ List<String> ips = new ArrayList<String>();
+ ips.add("ip1");
+ FirewallPolicy response = firewallpolicyApi().assignServerIp("firewallpolicyId", FirewallPolicy.ServerIp.CreateServerIp.create(ips));
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/firewall_policies/firewallpolicyId/server_ips", "{\"server_ips\":[\"ip1\"]}");
+ }
+
+ @Test
+ public void testUnassignServerIp() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/get.json"))
+ );
+ FirewallPolicy response = firewallpolicyApi().unassignServerIp("firewallpolicyId", "serverIpId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/firewall_policies/firewallpolicyId/server_ips/serverIpId");
+ }
+
+ @Test
+ public void testListRules() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/list.rules.json"))
+ );
+
+ List<FirewallPolicy.Rule> rules = firewallpolicyApi().listRules("firewallpolicyId");
+
+ assertNotNull(rules);
+ assertEquals(rules.size(), 2);
+
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies/firewallpolicyId/rules");
+ }
+
+ @Test
+ public void testListRules404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+
+ List<FirewallPolicy.Rule> rules = firewallpolicyApi().listRules("firewallpolicyId");
+
+ assertEquals(rules.size(), 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies/firewallpolicyId/rules");
+ }
+
+ @Test
+ public void testGetRule() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/get.rule.json"))
+ );
+ FirewallPolicy.Rule result = firewallpolicyApi().getRule("firewallpolicyId", "ruleId");
+
+ assertNotNull(result);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies/firewallpolicyId/rules/ruleId");
+ }
+
+ @Test
+ public void testGetRule404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ FirewallPolicy.Rule result = firewallpolicyApi().getRule("firewallpolicyId", "ruleId");
+
+ assertEquals(result, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/firewall_policies/firewallpolicyId/rules/ruleId");
+ }
+
+ @Test
+ public void testAddRule() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/get.json"))
+ );
+
+ List<FirewallPolicy.Rule.CreatePayload> rules = new ArrayList<FirewallPolicy.Rule.CreatePayload>();
+ FirewallPolicy.Rule.CreatePayload rule = FirewallPolicy.Rule.CreatePayload.builder()
+ .portFrom(80)
+ .portTo(80)
+ .protocol(Types.RuleProtocol.TCP)
+ .source("source")
+ .build();
+ rules.add(rule);
+ FirewallPolicy response = firewallpolicyApi().addRules("firewallpolicyId", FirewallPolicy.Rule.AddRule.create(rules));
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/firewall_policies/firewallpolicyId/rules", "{\"rules\":[{\"protocol\":\"TCP\",\"port_from\":80,\"port_to\":80,\"source\":\"source\"}]}");
+ }
+
+ @Test
+ public void testRemoveRule() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/firewallpolicies/get.json"))
+ );
+ FirewallPolicy response = firewallpolicyApi().removeRule("firewallpolicyId", "ruleId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/firewall_policies/firewallpolicyId/rules/ruleId");
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneApiMockTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneApiMockTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneApiMockTest.java
index f9bb74c..1f90aa5 100644
--- a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneApiMockTest.java
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneApiMockTest.java
@@ -42,7 +42,6 @@ public class BaseOneAndOneApiMockTest {
private static final OneAndOneProviderMetadata METADATA = new OneAndOneProviderMetadata();
protected static final String AUTH_HEADER = "token";
-
private static final String DEFAULT_ENDPOINT = METADATA.getEndpoint();
private final Set<Module> modules = ImmutableSet.<Module>of(new ExecutorServiceModule(sameThreadExecutor()));
protected MockWebServer server;
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneLiveTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneLiveTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneLiveTest.java
index 7045e45..b03b44c 100644
--- a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneLiveTest.java
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneLiveTest.java
@@ -102,6 +102,12 @@ public class BaseOneAndOneLiveTest extends BaseApiLiveTest<OneAndOneApi> {
.powerOn(Boolean.TRUE).build());
}
+ protected Server updateServerStatus(Server server) {
+ assertNodeAvailable(server);
+ return api.serverApi().get(server.id());
+
+ }
+
protected void assertNodeAvailable(Server server) {
assertTrue(waitUntilServerReady.apply(server), String.format("Server %s is not Ready", server));
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/firewallpolicies/get.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/firewallpolicies/get.json b/oneandone/src/test/resources/firewallpolicies/get.json
new file mode 100644
index 0000000..ab9cb98
--- /dev/null
+++ b/oneandone/src/test/resources/firewallpolicies/get.json
@@ -0,0 +1,26 @@
+{
+ "id": "83522FC7DA9172F229E5352C587075BA",
+ "name": "My firewall policy test",
+ "description": "My firewall policy description",
+ "state": "CONFIGURING",
+ "creation_date": "2015-04-29T10:43:11+00:00",
+ "default": 0,
+ "rules": [
+ {
+ "id": "DA5CC179ED00079AE7DE595F0073D86E",
+ "protocol": "TCP",
+ "port_from": 80,
+ "port_to": 80,
+ "source": "0.0.0.0"
+ },
+ {
+ "id": "0766EC674A0CD9D4EC0FA0B07978A649",
+ "protocol": "TCP",
+ "port_from": 443,
+ "port_to": 443,
+ "source": "0.0.0.0"
+ }
+ ],
+ "server_ips": [],
+ "cloudpanel_id": "FW99AA4_7"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/firewallpolicies/get.rule.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/firewallpolicies/get.rule.json b/oneandone/src/test/resources/firewallpolicies/get.rule.json
new file mode 100644
index 0000000..d941bd1
--- /dev/null
+++ b/oneandone/src/test/resources/firewallpolicies/get.rule.json
@@ -0,0 +1,7 @@
+{
+ "id": "353E9F751630074CF7219747436A8D71",
+ "protocol": "TCP",
+ "port_from": 4567,
+ "port_to": 4567,
+ "source": "0.0.0.0"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/firewallpolicies/get.serverip.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/firewallpolicies/get.serverip.json b/oneandone/src/test/resources/firewallpolicies/get.serverip.json
new file mode 100644
index 0000000..02b3e65
--- /dev/null
+++ b/oneandone/src/test/resources/firewallpolicies/get.serverip.json
@@ -0,0 +1,5 @@
+{
+ "id": "01D4A802798AB77AA72DA2D05E1379E1",
+ "ip": "10.5.135.140",
+ "server_name": "My Server 2"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/firewallpolicies/list.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/firewallpolicies/list.json b/oneandone/src/test/resources/firewallpolicies/list.json
new file mode 100644
index 0000000..e7d3f43
--- /dev/null
+++ b/oneandone/src/test/resources/firewallpolicies/list.json
@@ -0,0 +1,54 @@
+[
+ {
+ "id": "83522FC7DA9172F229E5352C587075BA",
+ "name": "My firewall policy test",
+ "description": "My firewall policy description",
+ "state": "CONFIGURING",
+ "creation_date": "2015-04-29T10:43:11+00:00",
+ "default": 0,
+ "rules": [
+ {
+ "id": "DA5CC179ED00079AE7DE595F0073D86E",
+ "protocol": "TCP",
+ "port_from": 80,
+ "port_to": 80,
+ "source": "0.0.0.0"
+ },
+ {
+ "id": "0766EC674A0CD9D4EC0FA0B07978A649",
+ "protocol": "TCP",
+ "port_from": 443,
+ "port_to": 443,
+ "source": "0.0.0.0"
+ }
+ ],
+ "server_ips": [],
+ "cloudpanel_id": "FW99AA4_7"
+ },
+ {
+ "id": "83522FC7DA9172F229E5352C587075B9",
+ "name": "My firewall policy test 2",
+ "description": "My firewall policy description",
+ "state": "CONFIGURING",
+ "creation_date": "2015-04-29T10:43:11+00:00",
+ "default": 0,
+ "rules": [
+ {
+ "id": "DA5CC179ED00079AE7DE595F0073D86F",
+ "protocol": "TCP",
+ "port_from": 80,
+ "port_to": 80,
+ "source": "0.0.0.0"
+ },
+ {
+ "id": "0766EC674A0CD9D4EC0FA0B07978A64A",
+ "protocol": "TCP",
+ "port_from": 443,
+ "port_to": 443,
+ "source": "0.0.0.0"
+ }
+ ],
+ "server_ips": [],
+ "cloudpanel_id": "FW99AA4_7"
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/firewallpolicies/list.options.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/firewallpolicies/list.options.json b/oneandone/src/test/resources/firewallpolicies/list.options.json
new file mode 100644
index 0000000..e7d3f43
--- /dev/null
+++ b/oneandone/src/test/resources/firewallpolicies/list.options.json
@@ -0,0 +1,54 @@
+[
+ {
+ "id": "83522FC7DA9172F229E5352C587075BA",
+ "name": "My firewall policy test",
+ "description": "My firewall policy description",
+ "state": "CONFIGURING",
+ "creation_date": "2015-04-29T10:43:11+00:00",
+ "default": 0,
+ "rules": [
+ {
+ "id": "DA5CC179ED00079AE7DE595F0073D86E",
+ "protocol": "TCP",
+ "port_from": 80,
+ "port_to": 80,
+ "source": "0.0.0.0"
+ },
+ {
+ "id": "0766EC674A0CD9D4EC0FA0B07978A649",
+ "protocol": "TCP",
+ "port_from": 443,
+ "port_to": 443,
+ "source": "0.0.0.0"
+ }
+ ],
+ "server_ips": [],
+ "cloudpanel_id": "FW99AA4_7"
+ },
+ {
+ "id": "83522FC7DA9172F229E5352C587075B9",
+ "name": "My firewall policy test 2",
+ "description": "My firewall policy description",
+ "state": "CONFIGURING",
+ "creation_date": "2015-04-29T10:43:11+00:00",
+ "default": 0,
+ "rules": [
+ {
+ "id": "DA5CC179ED00079AE7DE595F0073D86F",
+ "protocol": "TCP",
+ "port_from": 80,
+ "port_to": 80,
+ "source": "0.0.0.0"
+ },
+ {
+ "id": "0766EC674A0CD9D4EC0FA0B07978A64A",
+ "protocol": "TCP",
+ "port_from": 443,
+ "port_to": 443,
+ "source": "0.0.0.0"
+ }
+ ],
+ "server_ips": [],
+ "cloudpanel_id": "FW99AA4_7"
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/firewallpolicies/list.rules.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/firewallpolicies/list.rules.json b/oneandone/src/test/resources/firewallpolicies/list.rules.json
new file mode 100644
index 0000000..114a2f4
--- /dev/null
+++ b/oneandone/src/test/resources/firewallpolicies/list.rules.json
@@ -0,0 +1,16 @@
+[
+ {
+ "id": "DA5CC179ED00079AE7DE595F0073D86E",
+ "protocol": "TCP",
+ "port_from": 80,
+ "port_to": 80,
+ "source": "0.0.0.0"
+ },
+ {
+ "id": "0766EC674A0CD9D4EC0FA0B07978A649",
+ "protocol": "TCP",
+ "port_from": 443,
+ "port_to": 443,
+ "source": "0.0.0.0"
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/firewallpolicies/list.serverips.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/firewallpolicies/list.serverips.json b/oneandone/src/test/resources/firewallpolicies/list.serverips.json
new file mode 100644
index 0000000..14f14ea
--- /dev/null
+++ b/oneandone/src/test/resources/firewallpolicies/list.serverips.json
@@ -0,0 +1,7 @@
+[
+ {
+ "id": "01D4A802798AB77AA72DA2D05E1379E1",
+ "ip": "10.5.135.140",
+ "server_name": "My Server 2"
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/sharedStorage/get.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/sharedStorage/get.json b/oneandone/src/test/resources/sharedStorage/get.json
new file mode 100644
index 0000000..7f3d370
--- /dev/null
+++ b/oneandone/src/test/resources/sharedStorage/get.json
@@ -0,0 +1,24 @@
+{
+ "id": "6AD2F180B7B666539EF75A02FE227084",
+ "size": 200,
+ "state": "ACTIVE",
+ "description": "My shared storage test description",
+ "datacenter": {
+ "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36",
+ "location": "USA",
+ "country_code": "US"
+ },
+ "cloudpanel_id": "vid35780",
+ "size_used": "0.00",
+ "cifs_path": "\\vid50995.nas1.lan\\vid50995",
+ "nfs_path": "vid50995.nas1.lan/:vid50995",
+ "name": "My shared storage test",
+ "creation_date": "2015-05-06T08:33:25+00:00",
+ "servers": [
+ {
+ "id": "638ED28205B1AFD7ADEF569C725DD85F",
+ "name": "My server 1",
+ "rights": "RW"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/sharedStorage/list.access.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/sharedStorage/list.access.json b/oneandone/src/test/resources/sharedStorage/list.access.json
new file mode 100644
index 0000000..6b72404
--- /dev/null
+++ b/oneandone/src/test/resources/sharedStorage/list.access.json
@@ -0,0 +1,24 @@
+[
+ {
+ "datacenter": {
+ "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36",
+ "location": "USA",
+ "country_code": "US"
+ },
+ "state": "CONFIGURING",
+ "kerberos_content_file": "BQIAAABSAAIACERFVjEuTEFOAANuZnMAEnVpZDYyNDQ1OS5kZXYxLmxhbgAAAAEAAAAAQAASACAobHpZknT8WqX14kQhOrFI9hwO37NUg/p3Ne/8w2MPJA==",
+ "needs_password_reset": 0,
+ "user_domain": "nas2\\uid183564"
+ },
+ {
+ "datacenter": {
+ "id": "D0F6D8C8ED29D3036F94C27BBB789536",
+ "location": "Spain",
+ "country_code": "ES"
+ },
+ "state": "CONFIGURING",
+ "kerberos_content_file": "BQIAAABSAAIACERFVjEuTEFOAANuZnMAEnVpZDYyNDQ1OS5kZXYxLmxhbgAAAAEAAAAAQQASACAobHpZknT8WqX14kQhOrFI9hwO37NUg/p3Ne/8w2MPJA==",
+ "needs_password_reset": 0,
+ "user_domain": "nas2\\uid183564"
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/sharedStorage/list.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/sharedStorage/list.json b/oneandone/src/test/resources/sharedStorage/list.json
new file mode 100644
index 0000000..d9c8c93
--- /dev/null
+++ b/oneandone/src/test/resources/sharedStorage/list.json
@@ -0,0 +1,62 @@
+[
+ {
+ "id": "6AD2F180B7B666539EF75A02FE227084",
+ "size": 200,
+ "state": "ACTIVE",
+ "description": "My shared storage test description",
+ "datacenter": {
+ "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36",
+ "location": "USA",
+ "country_code": "US"
+ },
+ "cloudpanel_id": "vid35780",
+ "size_used": "0.00",
+ "cifs_path": "\\vid50995.nas1.lan\\vid50995",
+ "nfs_path": "vid50995.nas1.lan/:vid50995",
+ "name": "My shared storage test",
+ "creation_date": "2015-05-06T08:33:25+00:00",
+ "servers": [
+ {
+ "id": "638ED28205B1AFD7ADEF569C725DD85F",
+ "name": "My server 1",
+ "rights": "RW"
+ }
+ ]
+ },
+ {
+ "id": "4406CE4723BB441C7956E25C51CE8C1B",
+ "size": 50,
+ "state": "ACTIVE",
+ "description": "My shared storage description",
+ "datacenter": {
+ "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36",
+ "location": "USA",
+ "country_code": "US"
+ },
+ "cloudpanel_id": "vid30534",
+ "size_used": "0.00",
+ "cifs_path": "\\vid50995.nas1.lan\\vid50995",
+ "nfs_path": "vid50995.nas1.lan/:vid50995",
+ "name": "My shared storage",
+ "creation_date": "2015-03-17T11:57:48+00:00",
+ "servers": []
+ },
+ {
+ "id": "1A5418172DD3BD39F8010A6633F1018A",
+ "size": 250,
+ "state": "ACTIVE",
+ "description": null,
+ "cloudpanel_id": "vid19857",
+ "datacenter": {
+ "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36",
+ "location": "USA",
+ "country_code": "US"
+ },
+ "size_used": "0.00",
+ "cifs_path": "\\vid50995.nas1.lan\\vid50995",
+ "nfs_path": "vid50995.nas1.lan/:vid50995",
+ "name": "My shared storage 2",
+ "creation_date": "2015-05-05T09:36:31+00:00",
+ "servers": []
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/sharedStorage/list.options.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/sharedStorage/list.options.json b/oneandone/src/test/resources/sharedStorage/list.options.json
new file mode 100644
index 0000000..d9c8c93
--- /dev/null
+++ b/oneandone/src/test/resources/sharedStorage/list.options.json
@@ -0,0 +1,62 @@
+[
+ {
+ "id": "6AD2F180B7B666539EF75A02FE227084",
+ "size": 200,
+ "state": "ACTIVE",
+ "description": "My shared storage test description",
+ "datacenter": {
+ "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36",
+ "location": "USA",
+ "country_code": "US"
+ },
+ "cloudpanel_id": "vid35780",
+ "size_used": "0.00",
+ "cifs_path": "\\vid50995.nas1.lan\\vid50995",
+ "nfs_path": "vid50995.nas1.lan/:vid50995",
+ "name": "My shared storage test",
+ "creation_date": "2015-05-06T08:33:25+00:00",
+ "servers": [
+ {
+ "id": "638ED28205B1AFD7ADEF569C725DD85F",
+ "name": "My server 1",
+ "rights": "RW"
+ }
+ ]
+ },
+ {
+ "id": "4406CE4723BB441C7956E25C51CE8C1B",
+ "size": 50,
+ "state": "ACTIVE",
+ "description": "My shared storage description",
+ "datacenter": {
+ "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36",
+ "location": "USA",
+ "country_code": "US"
+ },
+ "cloudpanel_id": "vid30534",
+ "size_used": "0.00",
+ "cifs_path": "\\vid50995.nas1.lan\\vid50995",
+ "nfs_path": "vid50995.nas1.lan/:vid50995",
+ "name": "My shared storage",
+ "creation_date": "2015-03-17T11:57:48+00:00",
+ "servers": []
+ },
+ {
+ "id": "1A5418172DD3BD39F8010A6633F1018A",
+ "size": 250,
+ "state": "ACTIVE",
+ "description": null,
+ "cloudpanel_id": "vid19857",
+ "datacenter": {
+ "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36",
+ "location": "USA",
+ "country_code": "US"
+ },
+ "size_used": "0.00",
+ "cifs_path": "\\vid50995.nas1.lan\\vid50995",
+ "nfs_path": "vid50995.nas1.lan/:vid50995",
+ "name": "My shared storage 2",
+ "creation_date": "2015-05-05T09:36:31+00:00",
+ "servers": []
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/sharedStorage/server.get.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/sharedStorage/server.get.json b/oneandone/src/test/resources/sharedStorage/server.get.json
new file mode 100644
index 0000000..d68f370
--- /dev/null
+++ b/oneandone/src/test/resources/sharedStorage/server.get.json
@@ -0,0 +1,5 @@
+{
+ "id": "638ED28205B1AFD7ADEF569C725DD85F",
+ "name": "Mi servidor 1",
+ "rights": "RW"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/50744595/oneandone/src/test/resources/sharedStorage/servers.list.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/sharedStorage/servers.list.json b/oneandone/src/test/resources/sharedStorage/servers.list.json
new file mode 100644
index 0000000..e46295d
--- /dev/null
+++ b/oneandone/src/test/resources/sharedStorage/servers.list.json
@@ -0,0 +1,12 @@
+[
+ {
+ "id": "C72CF0A681B0CCE7EC624DD194D585C6",
+ "name": "My Server",
+ "rights": "RW"
+ },
+ {
+ "id": "4ECD9D188EB457317B2CF8F07885E7B4",
+ "name": "My Server 2",
+ "rights": "R"
+ }
+]
\ No newline at end of file