Repository: AnalogJ/lexicon

Issue:
[Regression on #PR-203] CloudNS authentication broken when `auth-id` supplied
Provider CloudNS fails to authenticate when using auth-id for authentication, rather than auth-subid or auth-subuser.

Line 146 in lexicon/providers/cloudns.py  reads `if self.is_given_option(self.options['auth_id']):`. It should instead should read `if self.is_given_option('auth_id'):`.

I've inlined a patch below which fixes this. Sorry if this is more effort for you than a PR.

    --- cloudns.py
    +++ cloudns.pr203fix.py
    @@ -143,7 +143,7 @@ 
             if not self.options['auth_password']:
                 raise Exception('No valid authentication data passed, expected: auth-password')
    
    -        if self._is_given_option(self.options['auth_id']):
    +        if self._is_given_option('auth_id'):
                 return {'auth-id': self.options['auth_id'], 'auth-password': self.options['auth_password']}
             elif self._is_given_option('auth_subid'):
                 return {'sub-auth-id': self.options['auth_subid'], 'auth-password': self.options['auth_password']}


Discussion:
Can I please get an update on this? Unlike the issues which have been updated in the meantime, **this bug breaks the whole program**.

I've already done the troubleshooting.

I've already described when it broke. 

I've already supplied the fix. 

All I need is some kind of indication that this is in progress - or anything further you might need me to do.
Hey @rwjs 
Sorry about the delay. I haven't taken a look at new issues for a bit since I've been travelling. 
In general it's much easier to merge PR's rather than patchsets since my automation is setup for it. I'll manually create a PR for this though. 

Unfortunately I can't test this change as I don't have a CloudNS account, but maybe @ppmathis can take some time and verify it. 
@AnalogJ Sure! :) Ping me once you have created the PR and I will gladly get it verified.

Resolving patch:
diff --git a/lexicon/providers/cloudns.py b/lexicon/providers/cloudns.py
--- a/lexicon/providers/cloudns.py
+++ b/lexicon/providers/cloudns.py
@@ -123,13 +123,13 @@ def delete_record(self, identifier=None, type=None, name=None, content=None):
             delete_record_id = [record['id'] for record in records]
         else:
             delete_record_id.append(identifier)
-        
+
         logger.debug('delete_records: %s', delete_record_id)
-        
+
         for record_id in delete_record_id:
             # Delete existing record by calling the ClouDNS API
             payload = self._post('/dns/delete-record.json', {'domain-name': self.domain_id, 'record-id': record_id})
-        
+
         logger.debug('delete_record: %s', True)
 
         # Error handling is already covered by self._request
@@ -143,7 +143,7 @@ def _build_authentication_data(self):
         if not self.options['auth_password']:
             raise Exception('No valid authentication data passed, expected: auth-password')
 
-        if self._is_given_option(self.options['auth_id']):
+        if self._is_given_option('auth_id'):
             return {'auth-id': self.options['auth_id'], 'auth-password': self.options['auth_password']}
         elif self._is_given_option('auth_subid'):
             return {'sub-auth-id': self.options['auth_subid'], 'auth-password': self.options['auth_password']}


Test patch: