def create_fake_client(response_type, is_public=False, require_consent=True): """ Create a test client, response_type argument MUST be: 'code', 'id_token' or 'id_token token'. Return a Client object. """ client = Client() client.name = 'Some Client' client.client_id = str(random.randint(1, 999999)).zfill(6) if is_public: client.client_type = 'public' client.client_secret = '' else: client.client_secret = str(random.randint(1, 999999)).zfill(6) client.redirect_uris = ['http://example.com/'] client.require_consent = require_consent client.scope = ['openid', 'email'] client.save() # check if response_type is a string in a python 2 and 3 compatible way if isinstance(response_type, ("".__class__, u"".__class__)): response_type = (response_type, ) for value in response_type: client.response_types.add(ResponseType.objects.get(value=value)) return client
def create_fake_client(response_type, is_public=False, require_consent=True): """ Create a test client, response_type argument MUST be: 'code', 'id_token' or 'id_token token'. Return a Client object. """ client = Client() client.name = 'Some Client' client.client_id = str(random.randint(1, 999999)).zfill(6) if is_public: client.client_type = 'public' client.client_secret = '' else: client.client_secret = str(random.randint(1, 999999)).zfill(6) client.redirect_uris = ['http://example.com/'] client.require_consent = require_consent client.save() # check if response_type is a string in a python 2 and 3 compatible way if isinstance(response_type, ("".__class__, u"".__class__)): response_type = (response_type,) for value in response_type: client.response_types.add(ResponseType.objects.get(value=value)) return client
def create_oidc_client(): factory = RequestFactory() client = Client() client.name = "OIDC" client.client_id = str(random.randint(1, 999999)).zfill(6) client.client_secret = str(random.randint(1, 999999)).zfill(6) client.redirect_uris = ['http://example.com/'] client.require_consent = False client.save() client.response_types.add(ResponseType.objects.get(value='code')) return client
def create_fake_client(response_type, is_public=False): """ Create a test client, response_type argument MUST be: 'code', 'id_token' or 'id_token token'. Return a Client object. """ client = Client() client.name = 'Some Client' client.client_id = str(random.randint(1, 999999)).zfill(6) if is_public: client.client_type = 'public' client.client_secret = '' else: client.client_secret = str(random.randint(1, 999999)).zfill(6) client.response_type = response_type client.redirect_uris = ['http://example.com/'] client.save() return client