--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use Test::More 'no_plan';
+use tests_common;
+use Data::Dumper;
+
+# Configuration variables defined in tests_common
+# Make sure those are updated/set correctly..
+# $api_base
+# $api_key
+#
+# Further variables defined in tests_common:
+# $invalid_key
+# $test_username
+# $test_password
+# $invalid_username
+
+my ($data, $temp, $test_domain);
+
+my $test_macaddress = '12341d6db76c';
+
+isa_ok( $g_ua, 'LWP::UserAgent', '$g_ua');
+isa_ok( $g_ua->cookie_jar, 'HTTP::Cookies', '$g_ua->cookies');
+
+login_apikey();
+
+# First: fetch a supported domain from the API...
+$data = exec_apinode("domain/list", undef);
+ok($data, 'domain/list JSON decode');
+is( $data->{'response'}, 'ok', 'domain/list result');
+ok($data->{'list'}, 'domain/list array');
+
+# NOW: Set the $test_domain to something useful (i.e. the first reported domain)
+$test_domain = $data->{'list'}[0];
+
+ok($test_domain, 'test_domain set.');
+undef $data;
+
+$data = exec_apinode("user/available", { "user" => $test_username . "\@" . $test_domain });
+is( $data->{'response'}, 'ok', 'user/available is available');
+undef $data;
+
+$data = exec_apinode("user/add_local", {
+ "user" => $test_username . "\@" . $test_domain,
+ "displayname" => "Automatic testing",
+ "email" => "noreply\@" . $test_domain,
+} );
+is( $data->{'response'}, 'ok', 'user/add_local created new account');
+
+$data = exec_apinode("phone/list", undef);
+is( $data->{'response'}, 'ok', 'phone/list result');
+ok($data->{'list'}, 'phone/list array');
+undef $data;
+
+$data = exec_apinode("phone/add", {
+ 'user' => $test_username . "\@" . $test_domain,
+ 'mac' => $test_macaddress,
+});
+
+is( $data->{'response'}, 'ok', 'phone/add result');
+ok($data->{'mac'}, 'phone/add mac set');
+ok($data->{'username'}, 'phone/add username set');
+ok($data->{'domain'}, 'phone/add domain set');
+undef $data;
+
+$data = exec_apinode("phone/list", { 'search' => $test_macaddress });
+is( $data->{'response'}, 'ok', 'phone/list search result');
+ok($data->{'list'}, 'phone/list search array');
+print Dumper($data->{'list'});
+
+undef $data;
+
+$data = exec_apinode("phone/get", { 'mac' => $test_macaddress });
+is( $data->{'response'}, 'ok', 'phone/get mac result');
+ok($data->{'list'}, 'phone/get mac array');
+undef $data;
+
+$data = exec_apinode("phone/get", { 'user' => $test_username . "\@" . $test_domain });
+is( $data->{'response'}, 'ok', 'phone/get user result');
+ok($data->{'list'}, 'phone/get user array');
+undef $data;
+
+$data = exec_apinode("phone/remove", {
+ 'user' => $test_username . "\@" . $test_domain,
+ 'mac' => $test_macaddress,
+});
+is( $data->{'response'}, 'ok', 'phone/remove result');
+ok($data->{'mac'}, 'phone/remove mac set');
+ok($data->{'username'}, 'phone/remove username set');
+ok($data->{'domain'}, 'phone/remove domain set');
+undef $data;
+
+$data = exec_apinode("user/remove", { "user" => $test_username . "\@" . $test_domain });
+is( $data->{'response'}, 'ok', 'user/remove deleted user');
+undef $data;
+
+
+logout();