You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by de...@apache.org on 2016/02/19 16:33:21 UTC

[11/35] jclouds git commit: JCLOUDS-702: JCloud ProfitBricks provider - NIC & Firewall API

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandlerTest.java b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandlerTest.java
new file mode 100644
index 0000000..a5fc74d
--- /dev/null
+++ b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandlerTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.profitbricks.http.parser.firewall;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.profitbricks.domain.Firewall;
+import org.jclouds.profitbricks.domain.ProvisioningState;
+import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "FirewallListResponseHandlerTest")
+public class FirewallListResponseHandlerTest extends BaseResponseHandlerTest<List<Firewall>> {
+
+   @Override
+   protected ParseSax<List<Firewall>> createParser() {
+      return factory.create(injector.getInstance(FirewallListResponseHandler.class));
+   }
+
+   @Test
+   public void testParseResponseFromGetAllFirewalls() {
+      ParseSax<List<Firewall>> parser = createParser();
+      List<Firewall> actual = parser.parse(payloadFromResource("/firewall/firewalls.xml"));
+      assertNotNull(actual, "Parsed content returned null");
+
+      List<Firewall> expected = ImmutableList.of(
+              Firewall.builder()
+              .active(true)
+              .id("firewall-id")
+              .nicId("nic-id")
+              .state(ProvisioningState.AVAILABLE)
+              .rules(ImmutableList.of(
+                              Firewall.Rule.builder()
+                              .id("firewall-rule-id")
+                              .name("name")
+                              .portRangeEnd(45678)
+                              .portRangeStart(12345)
+                              .protocol(Firewall.Protocol.TCP)
+                              .sourceIp("192.168.0.1")
+                              .sourceMac("aa:bb:cc:dd:ee:ff")
+                              .targetIp("192.168.0.2")
+                              .build()
+                      ))
+              .build(),
+              Firewall.builder()
+              .active(true)
+              .id("firewall-id2")
+              .nicId("nic-id")
+              .state(ProvisioningState.AVAILABLE)
+              .rules(ImmutableList.of(
+                              Firewall.Rule.builder()
+                              .id("firewall-rule-id2")
+                              .name("name")
+                              .portRangeEnd(56789)
+                              .portRangeStart(23456)
+                              .protocol(Firewall.Protocol.TCP)
+                              .sourceIp("192.168.0.2")
+                              .sourceMac("aa:bb:cc:dd:ee:ff")
+                              .targetIp("192.168.0.3")
+                              .build()
+                      ))
+              .build()
+      );
+
+      assertEquals(actual, expected);
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandlerTest.java b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandlerTest.java
new file mode 100644
index 0000000..eeb4cba
--- /dev/null
+++ b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandlerTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.profitbricks.http.parser.firewall;
+
+import java.util.List;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.profitbricks.domain.Firewall;
+import org.jclouds.profitbricks.domain.ProvisioningState;
+import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import org.jclouds.profitbricks.domain.Firewall.Protocol;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "FirewallResponseHandlerTest")
+public class FirewallResponseHandlerTest extends BaseResponseHandlerTest<Firewall> {
+
+   @Override
+   protected ParseSax<Firewall> createParser() {
+      return factory.create(injector.getInstance(FirewallResponseHandler.class));
+   }
+
+   @Test
+   public void testParseResponseFromGetFirewall() {
+      ParseSax<Firewall> parser = createParser();
+      Firewall actual = parser.parse(payloadFromResource("/firewall/firewall.xml"));
+      assertNotNull(actual, "Parsed content returned null");
+      List<Firewall.Rule> firewallRules = ImmutableList.of(
+              Firewall.Rule.builder()
+              .id("firewall-rule-id")
+              .name("name")
+              .portRangeEnd(45678)
+              .portRangeStart(12345)
+              .protocol(Protocol.TCP)
+              .sourceIp("192.168.0.1")
+              .sourceMac("aa:bb:cc:dd:ee:ff")
+              .targetIp("192.168.0.2")
+              .build());
+
+      Firewall expected = Firewall.builder()
+              .active(true)
+              .id("firewall-id")
+              .nicId("nic-id")
+              .state(ProvisioningState.AVAILABLE)
+              .rules(firewallRules)
+              .build();
+
+      assertEquals(expected, actual);
+
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandlerTest.java b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandlerTest.java
new file mode 100644
index 0000000..ee0cac0
--- /dev/null
+++ b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandlerTest.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.profitbricks.http.parser.nic;
+
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.profitbricks.domain.Firewall;
+import org.jclouds.profitbricks.domain.Nic;
+import org.jclouds.profitbricks.domain.ProvisioningState;
+import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "NicListResponseHandlerTest")
+public class NicListResponseHandlerTest extends BaseResponseHandlerTest<List<Nic>> {
+
+   @Override
+   protected ParseSax<List<Nic>> createParser() {
+      return factory.create(injector.getInstance(NicListResponseHandler.class));
+   }
+
+   @Test
+   public void testParseResponseFromGetAllNic() {
+      ParseSax<List<Nic>> parser = createParser();
+      List<Nic> actual = parser.parse(payloadFromResource("/nic/nics.xml"));
+      assertNotNull(actual, "Parsed content returned null");
+
+      List<Nic> expected = ImmutableList.of(
+              Nic.builder()
+              .dataCenterId("datacenter-id")
+              .id("nic-id")
+              .name("nic-name")
+              .lanId(1)
+              .internetAccess(true)
+              .serverId("server-id")
+              .ip("192.168.0.1")
+              .macAddress("mac-address")
+              .firewall(
+                      Firewall.builder()
+                      .active(true)
+                      .id("firewall-id")
+                      .nicId("nic-id")
+                      .state(ProvisioningState.AVAILABLE)
+                      .build()
+              )
+              .dhcpActive(true)
+              .gatewayIp("192.168.0.0")
+              .state(ProvisioningState.AVAILABLE)
+              .build(),
+              Nic.builder()
+              .dataCenterId("datacenter-id")
+              .id("nic-id2")
+              .name("nick")
+              .lanId(1)
+              .internetAccess(false)
+              .serverId("server-id")
+              .ips(ImmutableList.of(
+                              "192.168.0.2",
+                              "192.168.0.3",
+                              "192.168.0.4"
+                      ))
+              .macAddress("mac-address")
+              .firewall(
+                      Firewall.builder()
+                      .active(false)
+                      .id("firewall-id2")
+                      .nicId("nic-id")
+                      .state(ProvisioningState.AVAILABLE)
+                      .build()
+              )
+              .dhcpActive(false)
+              .gatewayIp("192.168.0.0")
+              .state(ProvisioningState.AVAILABLE)
+              .build()
+      );
+
+      assertEquals(actual, expected);
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicResponseHandlerTest.java b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicResponseHandlerTest.java
new file mode 100644
index 0000000..a14b0d4
--- /dev/null
+++ b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicResponseHandlerTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.profitbricks.http.parser.nic;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.profitbricks.domain.Firewall;
+import org.jclouds.profitbricks.domain.Nic;
+import org.jclouds.profitbricks.domain.ProvisioningState;
+import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "NicResponseHandlerTest")
+public class NicResponseHandlerTest extends BaseResponseHandlerTest<Nic> {
+
+   @Override
+   protected ParseSax<Nic> createParser() {
+      return factory.create(injector.getInstance(NicResponseHandler.class));
+   }
+
+   @Test
+   public void testParseResponseFromGetNic() {
+      ParseSax<Nic> parser = createParser();
+      Nic actual = parser.parse(payloadFromResource("/nic/nic.xml"));
+      assertNotNull(actual, "Parsed content returned null");
+
+      Nic expected = Nic.builder()
+              .id("12345678-abcd-efgh-ijkl-987654321000")
+              .dataCenterId("0")
+              .name("name")
+              .lanId(1)
+              .internetAccess(true)
+              .serverId("server-id")
+              .ip("192.168.0.1")
+              .macAddress("mac-address")
+              .dhcpActive(true)
+              .gatewayIp("gateway-ip")
+              .state(ProvisioningState.AVAILABLE)
+              .firewall(
+                      Firewall.builder()
+                      .active(true)
+                      .id("firewall-id")
+                      .nicId("nic-id")
+                      .state(ProvisioningState.AVAILABLE)
+                      .build())
+              .build();
+
+      assertEquals(actual, expected);
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/server/ServerInfoResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/server/ServerInfoResponseHandlerTest.java b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/server/ServerInfoResponseHandlerTest.java
index b050568..eb8feb9 100644
--- a/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/server/ServerInfoResponseHandlerTest.java
+++ b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/server/ServerInfoResponseHandlerTest.java
@@ -23,13 +23,18 @@ import org.jclouds.date.DateCodec;
 import org.jclouds.date.DateCodecFactory;
 import org.jclouds.http.functions.ParseSax;
 import org.jclouds.profitbricks.domain.AvailabilityZone;
+import org.jclouds.profitbricks.domain.Firewall;
+import org.jclouds.profitbricks.domain.Nic;
 import org.jclouds.profitbricks.domain.OsType;
 import org.jclouds.profitbricks.domain.ProvisioningState;
 import org.jclouds.profitbricks.domain.Server;
+import org.jclouds.profitbricks.domain.Storage;
 import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
 
 import org.testng.annotations.Test;
 
+import com.google.common.collect.ImmutableList;
+
 @Test(groups = "unit", testName = "ServerInfoResponseHandlerTest")
 public class ServerInfoResponseHandlerTest extends BaseResponseHandlerTest<Server> {
 
@@ -69,6 +74,37 @@ public class ServerInfoResponseHandlerTest extends BaseResponseHandlerTest<Serve
               .isNicHotUnPlug(true)
               .isDiscVirtioHotPlug(true)
               .isDiscVirtioHotUnPlug(true)
+              .storages(ImmutableList.<Storage>of(
+                              Storage.builder()
+                              .bootDevice(Boolean.TRUE)
+                              .busType(Storage.BusType.VIRTIO)
+                              .deviceNumber(1)
+                              .size(40f)
+                              .id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
+                              .name("facebook-storage")
+                              .build()
+                      )
+              )
+              .nics(ImmutableList.<Nic>of(
+                              Nic.builder()
+                              .dataCenterId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+                              .id("qwqwqwqw-wewe-erer-rtrt-tytytytytyty")
+                              .lanId(1)
+                              .internetAccess(true)
+                              .serverId("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
+                              .ip("173.252.120.6")
+                              .macAddress("02:01:09:cd:f0:b0")
+                              .firewall(Firewall.builder()
+                                      .active(false)
+                                      .id("wqwqwqwq-ewew-rere-trtr-ytytytytytyt")
+                                      .nicId("qwqwqwqw-wewe-erer-rtrt-tytytytytyty")
+                                      .state(ProvisioningState.AVAILABLE)
+                                      .build())
+                              .dhcpActive(true)
+                              .gatewayIp("173.252.120.1")
+                              .state(ProvisioningState.AVAILABLE)
+                              .build()
+                      ))
               .build();
 
       assertEquals(actual, expected);

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/server/ServerListResponseHandlerTest.java
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/server/ServerListResponseHandlerTest.java b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/server/ServerListResponseHandlerTest.java
index 09ee5bb..9f759cf 100644
--- a/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/server/ServerListResponseHandlerTest.java
+++ b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/server/ServerListResponseHandlerTest.java
@@ -17,7 +17,9 @@
 package org.jclouds.profitbricks.http.parser.server;
 
 import com.google.common.collect.ImmutableList;
+
 import java.util.List;
+
 import org.jclouds.date.DateCodec;
 import org.jclouds.date.DateCodecFactory;
 import org.jclouds.http.functions.ParseSax;
@@ -26,8 +28,13 @@ import org.jclouds.profitbricks.domain.OsType;
 import org.jclouds.profitbricks.domain.ProvisioningState;
 import org.jclouds.profitbricks.domain.Server;
 import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest;
+
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
+
+import org.jclouds.profitbricks.domain.Firewall;
+import org.jclouds.profitbricks.domain.Nic;
+import org.jclouds.profitbricks.domain.Storage;
 import org.testng.annotations.Test;
 
 @Test(groups = "unit", testName = "ServerListResponseHandlerTest")
@@ -70,6 +77,38 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
               .isNicHotUnPlug(true)
               .isDiscVirtioHotPlug(true)
               .isDiscVirtioHotUnPlug(true)
+              .storages(ImmutableList.<Storage>of(
+                              Storage.builder()
+                              .bootDevice(Boolean.TRUE)
+                              .busType(Storage.BusType.VIRTIO)
+                              .deviceNumber(1)
+                              .size(40f)
+                              .id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
+                              .name("facebook-storage")
+                              .build()
+                      )
+              )
+              .nics(ImmutableList.<Nic>of(
+                              Nic.builder()
+                              .dataCenterId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+                              .id("qwqwqwqw-wewe-erer-rtrt-tytytytytyty")
+                              .lanId(1)
+                              .internetAccess(true)
+                              .serverId("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
+                              .ip("173.252.120.6")
+                              .macAddress("02:01:09:cd:f0:b0")
+                              .firewall(Firewall.builder()
+                                      .active(false)
+                                      .id("wqwqwqwq-ewew-rere-trtr-ytytytytytyt")
+                                      .nicId("qwqwqwqw-wewe-erer-rtrt-tytytytytyty")
+                                      .state(ProvisioningState.AVAILABLE)
+                                      .build())
+                              .dhcpActive(true)
+                              .gatewayIp("173.252.120.1")
+                              .state(ProvisioningState.AVAILABLE)
+                              .build()
+                      )
+              )
               .build(),
               Server.builder()
               .id("asdfghjk-asdf-asdf-asdf-asdfghjklkjl")
@@ -89,6 +128,38 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
               .isNicHotUnPlug(true)
               .isDiscVirtioHotPlug(true)
               .isDiscVirtioHotUnPlug(true)
+              .storages(ImmutableList.<Storage>of(
+                              Storage.builder()
+                              .bootDevice(Boolean.TRUE)
+                              .busType(Storage.BusType.VIRTIO)
+                              .deviceNumber(1)
+                              .size(5f)
+                              .id("asfasfle-f23n-cu89-klfr-njkdsvwllkfa")
+                              .name("google-disk")
+                              .build()
+                      )
+              )
+              .nics(ImmutableList.<Nic>of(
+                              Nic.builder()
+                              .dataCenterId("qqqqqqqq-wwww-rrrr-tttt-yyyyyyyyyyyy")
+                              .id("mkl45h5e-sdgb-h6rh-235r-rfweshdfhreh")
+                              .lanId(3)
+                              .internetAccess(false)
+                              .serverId("asdfghjk-asdf-asdf-asdf-asdfghjklkjl")
+                              .ip("202.69.181.241")
+                              .macAddress("02:01:9e:5e:35:1e")
+                              .firewall(Firewall.builder()
+                                      .active(false)
+                                      .id("cvvdsgbd-sdgj-eger-h56j-wet43gvsgeg4")
+                                      .nicId("mkl45h5e-sdgb-h6rh-235r-rfweshdfhreh")
+                                      .state(ProvisioningState.INPROCESS)
+                                      .build())
+                              .dhcpActive(false)
+                              .gatewayIp("202.69.181.1")
+                              .state(ProvisioningState.AVAILABLE)
+                              .build()
+                      )
+              )
               .build()
       );
 

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/java/org/jclouds/profitbricks/util/MacAddressesTest.java
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/java/org/jclouds/profitbricks/util/MacAddressesTest.java b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/util/MacAddressesTest.java
new file mode 100644
index 0000000..1f0ae7a
--- /dev/null
+++ b/providers/profitbricks/src/test/java/org/jclouds/profitbricks/util/MacAddressesTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.profitbricks.util;
+
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import static org.jclouds.profitbricks.util.MacAddresses.isMacAddress;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "MacAddressesTest")
+public class MacAddressesTest {
+
+   private final List<String> expectedValidAddresses = ImmutableList.of(
+           "aa:bb:cc:dd:ee:ff", "11:22:33:44:55:66"
+   );
+   private final List<String> expectedInvalidAddresses = ImmutableList.of(
+           "AA:BB:CC:DD:EE:FF", "aa-bb-cc-dd-ee-ff", "", "aabbccddeeff",
+           "aa:bb:cc:dd:ff", "gg:aa:bb:cc:dd:ee"
+   );
+
+   @Test
+   public void testIsMacAddress() {
+      for (String addr : expectedValidAddresses)
+         assertTrue(isMacAddress(addr));
+
+      for (String addr : expectedInvalidAddresses)
+         assertFalse(isMacAddress(addr));
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/datacenter/datacenter.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/datacenter/datacenter.xml b/providers/profitbricks/src/test/resources/datacenter/datacenter.xml
index 9d8e20a..3df1f8b 100644
--- a/providers/profitbricks/src/test/resources/datacenter/datacenter.xml
+++ b/providers/profitbricks/src/test/resources/datacenter/datacenter.xml
@@ -30,13 +30,12 @@
                         <nicId>zzzzzzzz-xxxx-cccc-vvvv-bbbbbbbbbbbb</nicId>
                         <lanId>1</lanId>
                         <internetAccess>true</internetAccess>
-                        <serverId>12345678-abcd-efgh-ijkl-987654321000</serverId>
+                        <serverId>qqqqqqqq-wwww-eeee-rrrr-tttttttttttt</serverId>
                         <ips>202.94.38.12</ips>
                         <macAddress>02:01:09:cd:f0:b0</macAddress>
                         <firewall>
                             <active>false</active>
                             <firewallId>llllllll-kkkk-jjjj-hhhh-gggggggggggg</firewallId>
-                            <firewallId>62383ec1-38c8-486b-8fa2-a3bb0a5edd97</firewallId>
                             <nicId>zzzzzzzz-xxxx-cccc-vvvv-bbbbbbbbbbbb</nicId>
                             <provisioningState>AVAILABLE</provisioningState>
                         </firewall>

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/firewall/firewall-activate.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/firewall/firewall-activate.xml b/providers/profitbricks/src/test/resources/firewall/firewall-activate.xml
new file mode 100644
index 0000000..2150c6b
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/firewall/firewall-activate.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+  <S:Body>
+    <ns2:activateFirewallsResponse xmlns:ns2="http://ws.api.profitbricks.com/">
+      <return>
+        <requestId>request-id</requestId>
+        <dataCenterId>datacenter-id</dataCenterId>
+        <dataCenterVersion>datacenter-version</dataCenterVersion>
+      </return>
+    </ns2:activateFirewallsResponse>
+  </S:Body>
+</S:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/firewall/firewall-addtonic.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/firewall/firewall-addtonic.xml b/providers/profitbricks/src/test/resources/firewall/firewall-addtonic.xml
new file mode 100644
index 0000000..1267040
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/firewall/firewall-addtonic.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+  <S:Body>
+    <ns2:addFirewallRulesToNicResponse xmlns:ns2="http://ws.api.profitbricks.com/">
+ <return>
+    <active>active</active>
+    <firewallId>firewall-id</firewallId>
+    <firewallRules>
+      <firewallRuleId>firewall-rule-id</firewallRuleId>
+      <name>name</name>
+      <portRangeEnd>45678</portRangeEnd>
+      <portRangeStart>12345</portRangeStart>
+      <protocol>TCP</protocol>
+      <sourceIp>192.168.0.1</sourceIp>
+      <sourceMac>aa:bb:cc:dd:ee:ff</sourceMac>
+      <targetIp>192.168.0.2</targetIp>
+    </firewallRules>
+    <nicId>nic-id</nicId>
+    <provisioningState>AVAILABLE</provisioningState>
+  </return>
+    </ns2:addFirewallRulesToNicResponse>
+  </S:Body>
+</S:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/firewall/firewall-deactivate.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/firewall/firewall-deactivate.xml b/providers/profitbricks/src/test/resources/firewall/firewall-deactivate.xml
new file mode 100644
index 0000000..a0bca25
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/firewall/firewall-deactivate.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+  <S:Body>
+    <ns2:deactivateFirewallsResponse xmlns:ns2="http://ws.api.profitbricks.com/">
+      <return>
+        <requestId>request-id1111</requestId>
+        <dataCenterId>datacenter-id</dataCenterId>
+        <dataCenterVersion>datacenter-version</dataCenterVersion>
+      </return>
+    </ns2:deactivateFirewallsResponse>
+  </S:Body>
+</S:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/firewall/firewall-delete.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/firewall/firewall-delete.xml b/providers/profitbricks/src/test/resources/firewall/firewall-delete.xml
new file mode 100644
index 0000000..2c7364f
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/firewall/firewall-delete.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+  <S:Body>
+    <ns2:deleteFirewallsResponse xmlns:ns2="http://ws.api.profitbricks.com/">
+      <return>
+        <requestId>request-id</requestId>
+        <dataCenterId>datacenter-id</dataCenterId>
+        <dataCenterVersion>datacenter-version</dataCenterVersion>
+      </return>
+    </ns2:deleteFirewallsResponse>
+  </S:Body>
+</S:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/firewall/firewall-remove.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/firewall/firewall-remove.xml b/providers/profitbricks/src/test/resources/firewall/firewall-remove.xml
new file mode 100644
index 0000000..793bdd0
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/firewall/firewall-remove.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+  <S:Body>
+    <ns2:removeFirewallRulesResponse xmlns:ns2="http://ws.api.profitbricks.com/">
+      <return>
+        <requestId>request-id</requestId>
+        <dataCenterId>datacenter-id</dataCenterId>
+        <dataCenterVersion>datacenter-version</dataCenterVersion>
+      </return>
+    </ns2:removeFirewallRulesResponse>
+  </S:Body>
+</S:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/firewall/firewall.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/firewall/firewall.xml b/providers/profitbricks/src/test/resources/firewall/firewall.xml
new file mode 100644
index 0000000..3275a70
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/firewall/firewall.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+  <S:Body>
+    <ns2:getFirewallResponse xmlns:ns2="http://ws.api.profitbricks.com/">
+ <return>
+    <active>true</active>
+    <firewallId>firewall-id</firewallId>
+    <firewallRules>
+      <firewallRuleId>firewall-rule-id</firewallRuleId>
+      <name>name</name>
+      <portRangeEnd>45678</portRangeEnd>
+      <portRangeStart>12345</portRangeStart>
+      <protocol>TCP</protocol>
+      <sourceIp>192.168.0.1</sourceIp>
+      <sourceMac>aa:bb:cc:dd:ee:ff</sourceMac>
+      <targetIp>192.168.0.2</targetIp>
+    </firewallRules>
+    <nicId>nic-id</nicId>
+    <provisioningState>AVAILABLE</provisioningState>
+  </return>
+    </ns2:getFirewallResponse>
+  </S:Body>
+</S:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/firewall/firewalls.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/firewall/firewalls.xml b/providers/profitbricks/src/test/resources/firewall/firewalls.xml
new file mode 100644
index 0000000..5803fbf
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/firewall/firewalls.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+    <S:Body>
+        <ns2:getFirewallResponse xmlns:ns2="http://ws.api.profitbricks.com/">
+            <return>
+                <active>true</active>
+                <firewallId>firewall-id</firewallId>
+                <firewallRules>
+                    <firewallRuleId>firewall-rule-id</firewallRuleId>
+                    <name>name</name>
+                    <portRangeEnd>45678</portRangeEnd>
+                    <portRangeStart>12345</portRangeStart>
+                    <protocol>TCP</protocol>
+                    <sourceIp>192.168.0.1</sourceIp>
+                    <sourceMac>aa:bb:cc:dd:ee:ff</sourceMac>
+                    <targetIp>192.168.0.2</targetIp>
+                </firewallRules>
+                <nicId>nic-id</nicId>
+                <provisioningState>AVAILABLE</provisioningState>
+            </return>
+            <return>
+                <active>true</active>
+                <firewallId>firewall-id2</firewallId>
+                <firewallRules>
+                    <firewallRuleId>firewall-rule-id2</firewallRuleId>
+                    <name>name</name>
+                    <portRangeEnd>56789</portRangeEnd>
+                    <portRangeStart>23456</portRangeStart>
+                    <protocol>TCP</protocol>
+                    <sourceIp>192.168.0.2</sourceIp>
+                    <sourceMac>aa:bb:cc:dd:ee:ff</sourceMac>
+                    <targetIp>192.168.0.3</targetIp>
+                </firewallRules>
+                <nicId>nic-id</nicId>
+                <provisioningState>AVAILABLE</provisioningState>
+            </return>
+        </ns2:getFirewallResponse>
+    </S:Body>
+</S:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/nic/nic-create.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/nic/nic-create.xml b/providers/profitbricks/src/test/resources/nic/nic-create.xml
new file mode 100644
index 0000000..613313b
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/nic/nic-create.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+    <S:Body>
+        <ns2:createNicReturn xmlns:ns2="http://ws.api.profitbricks.com/">
+            <return>
+                <requestId>request-id</requestId>
+                <dataCenterId>datacenter-id</dataCenterId>
+                <dataCenterVersion>1</dataCenterVersion>
+                <nicId>nic-id</nicId>
+            </return>
+        </ns2:createNicReturn>
+    </S:Body>
+</S:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/nic/nic-delete.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/nic/nic-delete.xml b/providers/profitbricks/src/test/resources/nic/nic-delete.xml
new file mode 100644
index 0000000..0b5cc83
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/nic/nic-delete.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" ?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.api.profitbricks.com/">
+    <soapenv:Header/>
+    <soapenv:Body>
+        <ws:deleteNic>
+            <nicId>nic-id</nicId>
+        </ws:deleteNic>
+    </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/nic/nic-internetaccess.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/nic/nic-internetaccess.xml b/providers/profitbricks/src/test/resources/nic/nic-internetaccess.xml
new file mode 100644
index 0000000..6594894
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/nic/nic-internetaccess.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" ?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.api.profitbricks.com/">
+    <soapenv:Header/>
+    <soapenv:Body>
+        <ws:setInternetAccess>
+            <dataCenterId>datacenter-id</dataCenterId>
+            <lanId>1</lanId>
+            <internetAccess>internet-access</internetAccess>
+        </ws:setInternetAccess>
+    </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/nic/nic-update.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/nic/nic-update.xml b/providers/profitbricks/src/test/resources/nic/nic-update.xml
new file mode 100644
index 0000000..451914c
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/nic/nic-update.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" ?>
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.api.profitbricks.com/">
+    <soapenv:Header/>
+    <soapenv:Body>
+        <ws:updateNic>
+            <request>
+                <nicId>nic-id</nicId>
+                <ip>ip</ip>
+                <nicName>nic-name</nicName>
+                <dhcpActive>true</dhcpActive>
+                <lanId>1</lanId>
+            </request>
+        </ws:updateNic>
+    </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/nic/nic.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/nic/nic.xml b/providers/profitbricks/src/test/resources/nic/nic.xml
new file mode 100644
index 0000000..18adc23
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/nic/nic.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+    <S:Body>
+        <ns2:getNicResponse xmlns:ns2="http://ws.api.profitbricks.com/">
+            <return>
+                <nicId>12345678-abcd-efgh-ijkl-987654321000</nicId>
+                <dataCenterId>0</dataCenterId>
+                <dataCenterVersion>1</dataCenterVersion>
+                <lanId>1</lanId>
+                <nicName>name</nicName>
+                <internetAccess>true</internetAccess>
+                <serverId>server-id</serverId>
+                <ips>192.168.0.1</ips>
+                <macAddress>mac-address</macAddress>
+                <firewall>
+                    <active>true</active>
+                    <firewallId>firewall-id</firewallId>
+                    <nicId>nic-id</nicId>
+                    <provisioningState>AVAILABLE</provisioningState>
+                </firewall>
+                <dhcpActive>true</dhcpActive>
+                <gatewayIp>gateway-ip</gatewayIp>
+                <provisioningState>AVAILABLE</provisioningState>
+            </return>
+        </ns2:getNicResponse>
+    </S:Body>
+</S:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/nic/nics.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/nic/nics.xml b/providers/profitbricks/src/test/resources/nic/nics.xml
new file mode 100644
index 0000000..10e219d
--- /dev/null
+++ b/providers/profitbricks/src/test/resources/nic/nics.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+    <S:Body>
+        <ns2:getAllNicResponse xmlns:ns2="http://ws.api.profitbricks.com/">
+            <return>
+                <dataCenterId>datacenter-id</dataCenterId>
+                <dataCenterVersion>12</dataCenterVersion>
+                <nicId>nic-id</nicId>
+                <nicName>nic-name</nicName>
+                <lanId>1</lanId>
+                <internetAccess>true</internetAccess>
+                <serverId>server-id</serverId>
+                <ips>192.168.0.1</ips>
+                <macAddress>mac-address</macAddress>
+                <firewall>
+                    <active>true</active>
+                    <firewallId>firewall-id</firewallId>
+                    <nicId>nic-id</nicId>
+                    <provisioningState>AVAILABLE</provisioningState>
+                </firewall>
+                <dhcpActive>true</dhcpActive>
+                <gatewayIp>192.168.0.0</gatewayIp>
+                <provisioningState>AVAILABLE</provisioningState>
+            </return>
+            <return>
+                <dataCenterId>datacenter-id</dataCenterId>
+                <dataCenterVersion>21</dataCenterVersion>
+                <nicId>nic-id2</nicId>
+                <nicName>nick</nicName>
+                <lanId>1</lanId>
+                <internetAccess>false</internetAccess>
+                <serverId>server-id</serverId>
+                <ips>192.168.0.2</ips>
+                <ips>192.168.0.3</ips>
+                <ips>192.168.0.4</ips>
+                <macAddress>mac-address</macAddress>
+                <firewall>
+                    <active>false</active>
+                    <firewallId>firewall-id2</firewallId>
+                    <nicId>nic-id</nicId>
+                    <provisioningState>AVAILABLE</provisioningState>
+                </firewall>
+                <dhcpActive>false</dhcpActive>
+                <gatewayIp>192.168.0.0</gatewayIp>
+                <provisioningState>AVAILABLE</provisioningState>
+            </return>
+        </ns2:getAllNicResponse>
+    </S:Body>
+</S:Envelope>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds/blob/de2e5e01/providers/profitbricks/src/test/resources/server/servers.xml
----------------------------------------------------------------------
diff --git a/providers/profitbricks/src/test/resources/server/servers.xml b/providers/profitbricks/src/test/resources/server/servers.xml
index 4a74b5d..5da090f 100644
--- a/providers/profitbricks/src/test/resources/server/servers.xml
+++ b/providers/profitbricks/src/test/resources/server/servers.xml
@@ -84,6 +84,7 @@
                         <provisioningState>INPROCESS</provisioningState>
                     </firewall>
                     <dhcpActive>false</dhcpActive>
+                    <gatewayIp>202.69.181.1</gatewayIp>
                     <provisioningState>AVAILABLE</provisioningState>
                 </nics>
                 <provisioningState>AVAILABLE</provisioningState>