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 setUpTestData(cls): super(TestRedirectManagementMiddleware, cls).setUpTestData() cls.client_obj = Client(name="test_client", client_id="client_id_1", client_secret="super_client_secret_1", response_type="code", jwt_alg="HS256", redirect_uris=["http://example.com/"], terms_url="http://example-terms.com") cls.client_obj.save()
def setUpTestData(cls): super(TestLanguageUpdateMiddleware, cls).setUpTestData() cls.client_obj = Client(name="test_langauge_client", client_id="client_id_language", client_secret="super_client_secret_5", response_type="code", jwt_alg="HS256", redirect_uris=["http://example_one.com/"], terms_url="http://example-terms.com") cls.client_obj.save()
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 handle(self, *args, **options): name = options['name'][0] client_id = options['client_id'][0] client_secret = options['client_secret'] client_type = options['client_type'] response_type = options['response_type'][0] redirect_uris = options['redirect_uris'] reuse_consent = options['reuse_consent'] require_consent = options['require_consent'] c = Client(name=name, client_id=client_id, client_secret=client_secret, client_type=client_type, response_type=response_type, redirect_uris=redirect_uris, reuse_consent=reuse_consent, require_consent=require_consent) c.save()
def setUpTestData(cls): super(TestSessionMiddleware, cls).setUpTestData() cls.client = Client(name="test_client", client_id="client_id_1", client_secret="super_client_secret_1", response_type="code", jwt_alg="HS256", redirect_uris=["http://example.com/"]) cls.client.save() cls.user = get_user_model().objects.create(username="******", birth_date=datetime.date( 2000, 1, 1)) cls.user.set_password("P0ppy") cls.user.save()
def setUp(self): super().setUp() self.factory = RequestFactory() self.client = {} self.app = {} for index, name in enumerate(["Fancy chat tool", "Fancy wiki tool"]): self.client[index] = Client() self.client[index].name = name self.client[index].client_id = str(random.randint(1, 999999)).zfill(6) self.client[index].client_secret = str(random.randint( 1, 999999)).zfill(6) self.client[index].redirect_uris = ['http://example.com/'] self.client[index].require_consent = False self.client[index].save() self.client[index].response_types.add( ResponseType.objects.get(value='code')) self.app[index] = WebApplication(name=name, oidc_client=self.client[index]) self.app[index].save() self.state = uuid.uuid4().hex
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
def django_client(request): from django.test.client import Client return Client(SERVER_NAME=SERVER_NAME)