Browse Source

pep8 formatting

pull/12/head
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
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from .keycloak_openid 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)
if pol['type'] == 'resource':
from pprint import pprint
permission = Permission(name=pol['name'],
type=pol['type'],
logic=pol['logic'],
@ -86,4 +85,3 @@ class Authorization:
for policy_name in ast.literal_eval(pol['config']['applyPolicies']):
if self.policies.get(policy_name) is not None:
self.policies[policy_name].add_permission(permission)

1
keycloak/authorization/permission.py

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

3
keycloak/connection.py

@ -26,9 +26,10 @@ try:
except ImportError:
from urlparse import urljoin
from .exceptions import *
import requests
from .exceptions import (KeycloakConnectionError)
class ConnectionManager(object):
""" 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):
if expected_code == response.status_code:
if expected_code == requests.codes.no_content:
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
# 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 .keycloak_openid import KeycloakOpenID
from .urls_patterns import *
from .urls_patterns import (
URL_ADMIN_USERS,
)
from .connection import ConnectionManager
import json
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
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import json
from jose import jwt
from .authorization import Authorization
from .connection import ConnectionManager
from .exceptions import raise_error_from_response, KeycloakGetError, \
KeycloakRPTNotFound, KeycloakAuthorizationConfigError, KeycloakInvalidTokenError
from .urls_patterns import (
@ -33,9 +38,6 @@ from .urls_patterns import (
URL_ENTITLEMENT,
URL_INTROSPECT
)
from .connection import ConnectionManager
from jose import jwt
import json
class KeycloakOpenID:
@ -397,4 +399,3 @@ class KeycloakOpenID:
permissions += policy.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
try:
import unittest
except ImportError:
@ -47,7 +46,6 @@ class TestConnection(unittest.TestCase):
self.assertEqual(resp.status_code, 200)
def test_raw_post(self):
@urlmatch(path="/known_path", method="post")
def response_post_success(url, request):
headers = {'content-type': 'application/json'}
@ -74,7 +72,6 @@ class TestConnection(unittest.TestCase):
self.assertEqual(resp.status_code, 200)
def test_raw_get_fail(self):
@urlmatch(netloc="localhost", path="/known_path", method="get")
def response_get_fail(url, request):
headers = {'content-type': 'application/json'}
@ -88,7 +85,6 @@ class TestConnection(unittest.TestCase):
self.assertEqual(resp.status_code, 404)
def test_raw_post_fail(self):
@urlmatch(netloc="localhost", path="/known_path", method="post")
def response_post_fail(url, request):
headers = {'content-type': 'application/json'}
@ -102,7 +98,6 @@ class TestConnection(unittest.TestCase):
self.assertEqual(resp.status_code, 404)
def test_raw_put_fail(self):
@urlmatch(netloc="localhost", path="/known_path", method="put")
def response_put_fail(url, request):
headers = {'content-type': 'application/json'}

Loading…
Cancel
Save