Browse Source

pep8 formatting

hotfix/merge
Ewan Jones 6 years ago
parent
commit
4763a5f4ab
No known key found for this signature in database GPG Key ID: E34E7F21D7272734
  1. 2
      keycloak/__init__.py
  2. 2
      keycloak/authorization/__init__.py
  3. 1
      keycloak/authorization/permission.py
  4. 3
      keycloak/connection.py
  5. 1
      keycloak/exceptions.py
  6. 11
      keycloak/keycloak_admin.py
  7. 9
      keycloak/keycloak_openid.py
  8. 5
      keycloak/tests/test_connection.py

2
keycloak/__init__.py

@ -15,5 +15,5 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from .keycloak_openid import *
from .keycloak_admin import * from .keycloak_admin import *
from .keycloak_openid import *

2
keycloak/authorization/__init__.py

@ -75,7 +75,6 @@ class Authorization:
self.policies[policy_name].add_permission(permission) self.policies[policy_name].add_permission(permission)
if pol['type'] == 'resource': if pol['type'] == 'resource':
from pprint import pprint
permission = Permission(name=pol['name'], permission = Permission(name=pol['name'],
type=pol['type'], type=pol['type'],
logic=pol['logic'], logic=pol['logic'],
@ -86,4 +85,3 @@ class Authorization:
for policy_name in ast.literal_eval(pol['config']['applyPolicies']): for policy_name in ast.literal_eval(pol['config']['applyPolicies']):
if self.policies.get(policy_name) is not None: if self.policies.get(policy_name) is not None:
self.policies[policy_name].add_permission(permission) self.policies[policy_name].add_permission(permission)

1
keycloak/authorization/permission.py

@ -101,4 +101,3 @@ class Permission:
@scopes.setter @scopes.setter
def scopes(self, value): def scopes(self, value):
self._scopes = value self._scopes = value

3
keycloak/connection.py

@ -26,9 +26,10 @@ try:
except ImportError: except ImportError:
from urlparse import urljoin from urlparse import urljoin
from .exceptions import *
import requests import requests
from .exceptions import (KeycloakConnectionError)
class ConnectionManager(object): class ConnectionManager(object):
""" Represents a simple server connection. """ Represents a simple server connection.

1
keycloak/exceptions.py

@ -74,7 +74,6 @@ class KeycloakInvalidTokenError(KeycloakOperationError):
def raise_error_from_response(response, error, expected_code=200, skip_exists=False): def raise_error_from_response(response, error, expected_code=200, skip_exists=False):
if expected_code == response.status_code: if expected_code == response.status_code:
if expected_code == requests.codes.no_content: if expected_code == requests.codes.no_content:
return {} return {}

11
keycloak/keycloak_admin.py

@ -24,19 +24,16 @@
# Unless otherwise stated in the comments, "id", in e.g. user_id, refers to the # Unless otherwise stated in the comments, "id", in e.g. user_id, refers to the
# internal Keycloak server ID, usually a uuid string # internal Keycloak server ID, usually a uuid string
from .urls_patterns import *
from .keycloak_openid import KeycloakOpenID
import json
from .connection import ConnectionManager
from .exceptions import raise_error_from_response, KeycloakGetError from .exceptions import raise_error_from_response, KeycloakGetError
from .keycloak_openid import KeycloakOpenID
from .urls_patterns import *
from .urls_patterns import ( from .urls_patterns import (
URL_ADMIN_USERS, URL_ADMIN_USERS,
) )
from .connection import ConnectionManager
import json
class KeycloakAdmin: class KeycloakAdmin:

9
keycloak/keycloak_openid.py

@ -21,7 +21,12 @@
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import json
from jose import jwt
from .authorization import Authorization from .authorization import Authorization
from .connection import ConnectionManager
from .exceptions import raise_error_from_response, KeycloakGetError, \ from .exceptions import raise_error_from_response, KeycloakGetError, \
KeycloakRPTNotFound, KeycloakAuthorizationConfigError, KeycloakInvalidTokenError KeycloakRPTNotFound, KeycloakAuthorizationConfigError, KeycloakInvalidTokenError
from .urls_patterns import ( from .urls_patterns import (
@ -33,9 +38,6 @@ from .urls_patterns import (
URL_ENTITLEMENT, URL_ENTITLEMENT,
URL_INTROSPECT URL_INTROSPECT
) )
from .connection import ConnectionManager
from jose import jwt
import json
class KeycloakOpenID: class KeycloakOpenID:
@ -397,4 +399,3 @@ class KeycloakOpenID:
permissions += policy.permissions permissions += policy.permissions
return list(set(permissions)) return list(set(permissions))

5
keycloak/tests/test_connection.py

@ -19,7 +19,6 @@ from httmock import urlmatch, response, HTTMock, all_requests
from ..connection import ConnectionManager from ..connection import ConnectionManager
try: try:
import unittest import unittest
except ImportError: except ImportError:
@ -47,7 +46,6 @@ class TestConnection(unittest.TestCase):
self.assertEqual(resp.status_code, 200) self.assertEqual(resp.status_code, 200)
def test_raw_post(self): def test_raw_post(self):
@urlmatch(path="/known_path", method="post") @urlmatch(path="/known_path", method="post")
def response_post_success(url, request): def response_post_success(url, request):
headers = {'content-type': 'application/json'} headers = {'content-type': 'application/json'}
@ -74,7 +72,6 @@ class TestConnection(unittest.TestCase):
self.assertEqual(resp.status_code, 200) self.assertEqual(resp.status_code, 200)
def test_raw_get_fail(self): def test_raw_get_fail(self):
@urlmatch(netloc="localhost", path="/known_path", method="get") @urlmatch(netloc="localhost", path="/known_path", method="get")
def response_get_fail(url, request): def response_get_fail(url, request):
headers = {'content-type': 'application/json'} headers = {'content-type': 'application/json'}
@ -88,7 +85,6 @@ class TestConnection(unittest.TestCase):
self.assertEqual(resp.status_code, 404) self.assertEqual(resp.status_code, 404)
def test_raw_post_fail(self): def test_raw_post_fail(self):
@urlmatch(netloc="localhost", path="/known_path", method="post") @urlmatch(netloc="localhost", path="/known_path", method="post")
def response_post_fail(url, request): def response_post_fail(url, request):
headers = {'content-type': 'application/json'} headers = {'content-type': 'application/json'}
@ -102,7 +98,6 @@ class TestConnection(unittest.TestCase):
self.assertEqual(resp.status_code, 404) self.assertEqual(resp.status_code, 404)
def test_raw_put_fail(self): def test_raw_put_fail(self):
@urlmatch(netloc="localhost", path="/known_path", method="put") @urlmatch(netloc="localhost", path="/known_path", method="put")
def response_put_fail(url, request): def response_put_fail(url, request):
headers = {'content-type': 'application/json'} headers = {'content-type': 'application/json'}

Loading…
Cancel
Save