def test_check_and_update_grants(self): redirect_uri = 'http://localhost' # create a user user = self._create_user('anna', '123456') user2 = self._create_user('bob', '123456') capability_a = self._create_capability('Capability A', []) capability_b = self._create_capability('Capability B', []) # create an application and add capabilities application = self._create_application( 'an app', grant_type=Application.GRANT_AUTHORIZATION_CODE, redirect_uris=redirect_uri) application.scope.add(capability_a, capability_b) AccessToken.objects.create( token="existingtoken", user=user, application=application, expires=timezone.now() + timedelta(seconds=10), ) checks = check_grants() self.assertGreater( checks['unique_tokens'], checks['grants'], ) update_grants() checks = check_grants() self.assertEqual( checks['unique_tokens'], checks['grants'], ) # create expired token AccessToken.objects.create( token="expiredtoken", user=user2, application=application, expires=timezone.now() - timedelta(seconds=10), ) checks = check_grants() self.assertEqual( checks['unique_tokens'], checks['grants'], ) update_grants() checks = check_grants() self.assertEqual( checks['unique_tokens'], checks['grants'], )
def handle(self, *args, **options): g = create_group() u = create_user(g) a = create_application(u, g) t = create_test_token(u, a) update_grants() print("Name:", a.name) print("client_id:", a.client_id) print("client_secret:", a.client_secret) print("access_token:", t.token) print("redirect_uri:", a.redirect_uris)
def handle(self, *args, **options): # BB2-291, 373 support bfd v2 feature flag g_v2_partners = create_group("BFDV2Partners") g = create_group() u = create_user(g) u.groups.add(g_v2_partners) a = create_application(u, g) t = create_test_token(u, a) update_grants() print("Name:", a.name) print("client_id:", a.client_id) print("client_secret:", a.client_secret) print("access_token:", t.token) print("redirect_uri:", a.redirect_uris)
def handle(self, *args, **options): g = create_group() create_dev_users_apps_and_bene_crosswalks(g) # update grants update_grants()
def post(self, request, format=None): return Response(update_grants())
def migrate_grants(*args, **kwargs): update_grants()