Skip to content

Commit

Permalink
Raising when not successful and rerun live tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtakaniok committed Aug 7, 2023
1 parent 1007340 commit a5c637d
Show file tree
Hide file tree
Showing 27 changed files with 2,828 additions and 1,541 deletions.
22 changes: 11 additions & 11 deletions lexicon/providers/wedos.py
Expand Up @@ -5,7 +5,7 @@

import requests

from lexicon.exceptions import AuthenticationError
from lexicon.exceptions import AuthenticationError, LexiconError
from lexicon.providers.base import Provider as BaseProvider

NAMESERVER_DOMAINS = [
Expand Down Expand Up @@ -97,13 +97,13 @@ def _create_record(self, rtype: str, name: str, content: str) -> bool:
payload = self._post(data=self._create_payload('dns-row-add', data))
code = payload["response"]["code"]
if code == 1000:
validation = self._validate_changes()
validation = self._commit_changes()
if validation:
return True
else:
return False
raise LexiconError("Cannot commit changes")
else:
return False
raise LexiconError("Cannot create records")

def _list_records(self, rtype: Optional[str] = None, name: Optional[str] = None, content: Optional[str] = None) -> \
List[Dict]:
Expand Down Expand Up @@ -155,13 +155,13 @@ def _update_record(self, identifier: Optional[str] = None, rtype: Optional[str]
payloads.append(self._post(data=self._create_payload('dns-row-update', data)))

if all(payload["response"]["code"] == 1000 for payload in payloads):
validation = self._validate_changes()
validation = self._commit_changes()
if validation:
return True
else:
return False
raise LexiconError("Cannot commit changes")
else:
return False
raise LexiconError("Cannot update records")

def _delete_record(self, identifier: Optional[str] = None, rtype: Optional[str] = None, name: Optional[str] = None,
content: Optional[str] = None) -> bool:
Expand All @@ -182,15 +182,15 @@ def _delete_record(self, identifier: Optional[str] = None, rtype: Optional[str]
payloads.append(self._post(data=self._create_payload('dns-row-delete', data)))

if all(payload["response"]["code"] == 1000 for payload in payloads):
validation = self._validate_changes()
validation = self._commit_changes()
if validation:
return True
else:
return False
raise LexiconError("Cannot commit changes")
else:
return False
raise LexiconError("Cannot delete records")

def _validate_changes(self) -> bool:
def _commit_changes(self) -> bool:
data = {
'name': self.domain_id
}
Expand Down
Expand Up @@ -18,7 +18,7 @@ interactions:
uri: https://api.wedos.com/wapi/json
response:
body:
string: '{"response":{"code":1000,"result":"OK","timestamp":1691331810,"svTRID":"1691331810.4370.17710.1","command":"dns-domains-list","data":{"domain":[{"name":"kaniok.com","type":"primary","status":"active"}]}}}'
string: '{"response":{"code":1000,"result":"OK","timestamp":1691419076,"svTRID":"1691419076.0616.9683.1","command":"dns-domains-list","data":{"domain":[{"name":"kaniok.com","type":"primary","status":"active"}]}}}'
headers:
Cache-Control:
- max-age=0
Expand All @@ -27,9 +27,9 @@ interactions:
Content-Type:
- text/html; charset=UTF-8
Date:
- Sun, 06 Aug 2023 14:23:30 GMT
- Mon, 07 Aug 2023 14:37:56 GMT
Expires:
- Sun, 06 Aug 2023 14:23:30 GMT
- Mon, 07 Aug 2023 14:37:56 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand All @@ -41,7 +41,7 @@ interactions:
X-Frame-Options:
- ALLOW-FROM https://blog.wedos.cz
content-length:
- '204'
- '203'
status:
code: 200
message: OK
Expand Down
Expand Up @@ -18,7 +18,7 @@ interactions:
uri: https://api.wedos.com/wapi/json
response:
body:
string: '{"response":{"code":1000,"result":"OK","timestamp":1691331810,"svTRID":"1691331810.6088.19829.1","command":"dns-domains-list","data":{"domain":[{"name":"kaniok.com","type":"primary","status":"active"}]}}}'
string: '{"response":{"code":1000,"result":"OK","timestamp":1691419076,"svTRID":"1691419076.2502.9630.1","command":"dns-domains-list","data":{"domain":[{"name":"kaniok.com","type":"primary","status":"active"}]}}}'
headers:
Cache-Control:
- max-age=0
Expand All @@ -27,9 +27,9 @@ interactions:
Content-Type:
- text/html; charset=UTF-8
Date:
- Sun, 06 Aug 2023 14:23:30 GMT
- Mon, 07 Aug 2023 14:37:56 GMT
Expires:
- Sun, 06 Aug 2023 14:23:30 GMT
- Mon, 07 Aug 2023 14:37:56 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand All @@ -41,7 +41,7 @@ interactions:
X-Frame-Options:
- ALLOW-FROM https://blog.wedos.cz
content-length:
- '204'
- '203'
status:
code: 200
message: OK
Expand Down
Expand Up @@ -18,7 +18,7 @@ interactions:
uri: https://api.wedos.com/wapi/json
response:
body:
string: '{"response":{"code":1000,"result":"OK","timestamp":1691331810,"svTRID":"1691331810.7610.19895.1","command":"dns-domains-list","data":{"domain":[{"name":"kaniok.com","type":"primary","status":"active"}]}}}'
string: '{"response":{"code":1000,"result":"OK","timestamp":1691419076,"svTRID":"1691419076.4040.9534.1","command":"dns-domains-list","data":{"domain":[{"name":"kaniok.com","type":"primary","status":"active"}]}}}'
headers:
Cache-Control:
- max-age=0
Expand All @@ -27,9 +27,9 @@ interactions:
Content-Type:
- text/html; charset=UTF-8
Date:
- Sun, 06 Aug 2023 14:23:30 GMT
- Mon, 07 Aug 2023 14:37:56 GMT
Expires:
- Sun, 06 Aug 2023 14:23:30 GMT
- Mon, 07 Aug 2023 14:37:56 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand All @@ -41,7 +41,7 @@ interactions:
X-Frame-Options:
- ALLOW-FROM https://blog.wedos.cz
content-length:
- '204'
- '203'
status:
code: 200
message: OK
Expand All @@ -64,31 +64,12 @@ interactions:
uri: https://api.wedos.com/wapi/json
response:
body:
string: '{"response":{"code":1000,"result":"OK","timestamp":1691331810,"svTRID":"1691331810.9224.20094.1","command":"dns-rows-list","data":{"row":[{"ID":"24569","name":"","ttl":"1800","rdtype":"MX","rdata":"10
string: '{"response":{"code":1000,"result":"OK","timestamp":1691419076,"svTRID":"1691419076.5321.9543.1","command":"dns-rows-list","data":{"row":[{"ID":"24569","name":"","ttl":"1800","rdtype":"MX","rdata":"10
mx.zohomail.com","changed_date":"2014-07-01 18:01:26","author_comment":""},{"ID":"24570","name":"","ttl":"1800","rdtype":"MX","rdata":"20
mx2.zohomail.com","changed_date":"2014-07-01 18:01:32","author_comment":""},{"ID":"156455","name":"","ttl":"300","rdtype":"TXT","rdata":"v=spf1
include:zoho.com ~all","changed_date":"2023-08-03 17:58:48","author_comment":""},{"ID":"156857","name":"docs.kaniok.com","ttl":"3600","rdtype":"CNAME","rdata":"docs.example.com","changed_date":"2023-08-06
15:47:39","author_comment":""},{"ID":"156856","name":"localhost.kaniok.com","ttl":"3600","rdtype":"A","rdata":"127.0.0.1","changed_date":"2023-08-06
15:47:38","author_comment":""},{"ID":"156879","name":"orig.nameonly.test.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:47:59","author_comment":""},{"ID":"156878","name":"orig.test.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:47:58","author_comment":""},{"ID":"156880","name":"orig.testfqdn.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:47:59","author_comment":""},{"ID":"156881","name":"orig.testfull.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:48:01","author_comment":""},{"ID":"156875","name":"random.fqdntest.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:47:54","author_comment":""},{"ID":"156876","name":"random.fulltest.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:47:55","author_comment":""},{"ID":"156877","name":"random.test.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:47:56","author_comment":""},{"ID":"156872","name":"ttl.fqdn.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"ttlshouldbe3600","changed_date":"2023-08-06
15:47:52","author_comment":""},{"ID":"156454","name":"zoho._domainkey","ttl":"300","rdtype":"TXT","rdata":"v=DKIM1;
include:zoho.com ~all","changed_date":"2023-08-03 17:58:48","author_comment":""},{"ID":"156454","name":"zoho._domainkey","ttl":"300","rdtype":"TXT","rdata":"v=DKIM1;
k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCWhjQdWWVh0Ip6tAaanPvQJxPjZDFjwqX6Lvk98dHdGj+KtoCXBBESgfplHtUrgCHZMVpuUVAWxehhrlzLlJw7u6hHI\/M3oygK9NyT8a8VXX30tUUkPDdKmhIqpmFyg1EHiEhci1U2Acox5j1cPWPrDnd9oGlRwbxcvexXN4lAiQIDAQAB","changed_date":"2023-08-03
17:58:31","author_comment":""},{"ID":"156861","name":"_acme-challenge.createrecordset.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken1","changed_date":"2023-08-06
15:47:41","author_comment":""},{"ID":"156862","name":"_acme-challenge.createrecordset.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken2","changed_date":"2023-08-06
15:47:42","author_comment":""},{"ID":"156869","name":"_acme-challenge.deleterecordinset.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken2","changed_date":"2023-08-06
15:47:49","author_comment":""},{"ID":"156858","name":"_acme-challenge.fqdn.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:47:39","author_comment":""},{"ID":"156859","name":"_acme-challenge.full.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:47:40","author_comment":""},{"ID":"156873","name":"_acme-challenge.listrecordset.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken1","changed_date":"2023-08-06
15:47:53","author_comment":""},{"ID":"156874","name":"_acme-challenge.listrecordset.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken2","changed_date":"2023-08-06
15:47:54","author_comment":""},{"ID":"156863","name":"_acme-challenge.noop.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:47:42","author_comment":""},{"ID":"156860","name":"_acme-challenge.test.kaniok.com","ttl":"3600","rdtype":"TXT","rdata":"challengetoken","changed_date":"2023-08-06
15:47:41","author_comment":""}]}}}'
17:58:31","author_comment":""}]}}}'
headers:
Cache-Control:
- max-age=0
Expand All @@ -97,9 +78,9 @@ interactions:
Content-Type:
- text/html; charset=UTF-8
Date:
- Sun, 06 Aug 2023 14:23:30 GMT
- Mon, 07 Aug 2023 14:37:56 GMT
Expires:
- Sun, 06 Aug 2023 14:23:30 GMT
- Mon, 07 Aug 2023 14:37:56 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand All @@ -111,7 +92,99 @@ interactions:
X-Frame-Options:
- ALLOW-FROM https://blog.wedos.cz
content-length:
- '4082'
- '937'
status:
code: 200
message: OK
- request:
body: request%253D%257B%2522request%2522%253A%2B%257B%2522user%2522%253A%2B%2522username%2522%252C%2B%2522auth%2522%253A%2B%2522password%2522%252C%2B%2522command%2522%253A%2B%2522dns-row-add%2522%252C%2B%2522data%2522%253A%2B%257B%2522type%2522%253A%2B%2522A%2522%252C%2B%2522name%2522%253A%2B%2522localhost.kaniok.com%2522%252C%2B%2522rdata%2522%253A%2B%2522127.0.0.1%2522%252C%2B%2522domain%2522%253A%2B%2522kaniok.com%2522%252C%2B%2522ttl%2522%253A%2B3600%257D%257D%257D
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '363'
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- python-requests/2.28.2
method: POST
uri: https://api.wedos.com/wapi/json
response:
body:
string: '{"response":{"code":1000,"result":"OK","timestamp":1691419076,"svTRID":"1691419076.6729.9531.1","command":"dns-row-add"}}'
headers:
Cache-Control:
- max-age=0
Connection:
- Keep-Alive
Content-Type:
- text/html; charset=UTF-8
Date:
- Mon, 07 Aug 2023 14:37:56 GMT
Expires:
- Mon, 07 Aug 2023 14:37:56 GMT
Keep-Alive:
- timeout=5, max=100
Server:
- Apache
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
X-Frame-Options:
- ALLOW-FROM https://blog.wedos.cz
content-length:
- '121'
status:
code: 200
message: OK
- request:
body: request%253D%257B%2522request%2522%253A%2B%257B%2522user%2522%253A%2B%2522username%2522%252C%2B%2522auth%2522%253A%2B%2522password%2522%252C%2B%2522command%2522%253A%2B%2522dns-domain-commit%2522%252C%2B%2522data%2522%253A%2B%257B%2522name%2522%253A%2B%2522kaniok.com%2522%257D%257D%257D
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '243'
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- python-requests/2.28.2
method: POST
uri: https://api.wedos.com/wapi/json
response:
body:
string: '{"response":{"code":1000,"result":"OK","timestamp":1691419076,"svTRID":"1691419076.8648.9535.1","command":"dns-domain-commit"}}'
headers:
Cache-Control:
- max-age=0
Connection:
- Keep-Alive
Content-Type:
- text/html; charset=UTF-8
Date:
- Mon, 07 Aug 2023 14:37:56 GMT
Expires:
- Mon, 07 Aug 2023 14:37:56 GMT
Keep-Alive:
- timeout=5, max=100
Server:
- Apache
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
X-Frame-Options:
- ALLOW-FROM https://blog.wedos.cz
content-length:
- '127'
status:
code: 200
message: OK
Expand Down

0 comments on commit a5c637d

Please sign in to comment.