-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
195 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
Filtering records. | ||
search domains by Filtering. | ||
export to file (?import) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import unittest | ||
from clouddns.authentication import BaseAuthentication as Auth | ||
from misc import printdoc | ||
|
||
|
||
class AuthenticationTest(unittest.TestCase): | ||
""" | ||
Freerange Authentication class tests. | ||
""" | ||
|
||
def test_get_uri(self): | ||
""" | ||
Validate authentication uri construction. | ||
""" | ||
self.assert_(self.auth.uri == "v1.0", \ | ||
"authentication URL was not properly constructed") | ||
|
||
@printdoc | ||
def test_authenticate(self): | ||
""" | ||
Sanity check authentication method stub (lame). | ||
""" | ||
self.assert_(self.auth.authenticate() == (None, None, None), \ | ||
"authenticate() did not return a two-tuple") | ||
|
||
@printdoc | ||
def test_headers(self): | ||
""" | ||
Ensure headers are being set. | ||
""" | ||
self.assert_(self.auth.headers['x-auth-user'] == 'jsmith', \ | ||
"storage user header not properly assigned") | ||
self.assert_(self.auth.headers['x-auth-key'] == 'xxxxxxxx', \ | ||
"storage password header not properly assigned") | ||
|
||
def setUp(self): | ||
self.auth = Auth('jsmith', 'xxxxxxxx') | ||
|
||
def tearDown(self): | ||
del self.auth | ||
|
||
# vim:set ai ts=4 tw=0 sw=4 expandtab: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# -*- encoding: utf-8 -*- | ||
__author__ = "Chmouel Boudjnah <[email protected]>" | ||
import clouddns | ||
import os | ||
|
||
US_RCLOUD_USER = os.environ.get("US_RCLOUD_USER") | ||
US_RCLOUD_KEY = os.environ.get("US_RCLOUD_KEY") | ||
CNX = None | ||
|
||
def auth(): | ||
global CNX | ||
if not CNX: | ||
CNX = clouddns.connection.Connection(US_RCLOUD_USER, US_RCLOUD_KEY) | ||
return CNX | ||
|
||
|
||
def test_create_delete(cnx): | ||
# CREATE | ||
domain_created = cnx.create_domain(name="chmoutest21.com", | ||
ttl=300, | ||
emailAddress="[email protected]") | ||
# Delete | ||
cnx.delete_domain(domain_created.id) | ||
|
||
|
||
def test(): | ||
cnx = auth() | ||
#test_create_delete(cnx) | ||
|
||
# Domain list | ||
all_domains = cnx.get_domains() | ||
# __getitem__ | ||
domain = all_domains[0] | ||
# __getslice__ | ||
domain = all_domains[0:1][0] | ||
# __contains__ | ||
assert(str(domain) in all_domains) | ||
# __len__ | ||
len(all_domains) | ||
|
||
for x in all_domains: | ||
if str(x).startswith("chmoutest"): | ||
print "Cleaning: %s" % (x.name) | ||
cnx.delete_domain(x.id) | ||
|
||
# Create Domain | ||
domain_created = cnx.create_domain(name="chmoutesting.com", | ||
ttl=300, | ||
emailAddress="[email protected]") | ||
|
||
domain = domain_created | ||
|
||
ttl = 500 | ||
# Update Domain | ||
domain.update(ttl=ttl) | ||
|
||
assert(domain.ttl == ttl) | ||
|
||
# Get All records | ||
records = domain.get_records() | ||
record = records[0] | ||
|
||
# Get Record by ID | ||
record_id = record.id | ||
record = domain.get_record(record_id) | ||
|
||
from IPython.Shell import IPShellEmbed;IPShellEmbed()() | ||
|
||
test() |