Esempio n. 1
0
    def test_wrong_api_credentials(self):
        new_name = "This wont be created"
        options = {
            "provisioning_api_key": "abc",
            "provisioning_api_secret": "abc"
        }
        account_config(**options)
        with self.assertRaises(AuthorizationRequired):
            cloudinary.provisioning.create_sub_account(new_name, enabled=True)
        reset_config()

        assert True
Esempio n. 2
0
    def setUpClass(cls):
        now = datetime.now().strftime("%m-%d-%Y")
        cls.user_name_1 = "SDK TEST " + now
        cls.user_name_2 = "SDK TEST 2 " + now
        user_email_1 = "sdk-test" + now + "@cloudinary.com"
        user_email_2 = "sdk-test2" + now + "@cloudinary.com"
        user_role = "billing"

        reset_config()
        config = account_config()
        if not config.account_id or not config.provisioning_api_key or not config.provisioning_api_secret:
            return

        create_sub_account_res = cloudinary.provisioning.create_sub_account(
            "justname" + now, enabled=True)
        cls.cloud_id = create_sub_account_res["id"]

        create_user_1 = cloudinary.provisioning.create_user(
            cls.user_name_1, user_email_1, user_role)
        cls.user_id_1 = create_user_1["id"]

        create_user_2 = cloudinary.provisioning.create_user(
            cls.user_name_2, user_email_2, user_role)
        cls.user_id_2 = create_user_2["id"]

        create_user_group = cloudinary.provisioning.create_user_group(
            "test-group-" + now)
        cls.group_id = create_user_group["id"]
Esempio n. 3
0
 def test_parse_cloudinary_account_url(self):
     config = account_config()
     parsed_url = config._parse_cloudinary_url(
         'account://*****:*****@test123?foo[bar]=value')
     config._setup_from_parsed_url(parsed_url)
     foo = config.__dict__.get('foo')
     self.assertIsNotNone(foo)
     self.assertEqual(foo.get('bar'), 'value')
Esempio n. 4
0
 def test_cloudinary_account_url_valid_scheme(self):
     config = account_config()
     cloudinary_account_urls = [
         'account://*****:*****@test'
         'aCCouNT://*****:*****@test'
     ]
     for cloudinary_account_url in cloudinary_account_urls:
         parsed_url = config._parse_cloudinary_url(cloudinary_account_url)
         config._setup_from_parsed_url(parsed_url)
    def tearDownClass(cls):
        config = account_config()
        if not config.account_id or not config.provisioning_api_key or not config.provisioning_api_secret:
            return
        delete_sub_account = cloudinary.provisioning.delete_sub_account(
            cls.cloud_id)
        assert delete_sub_account["message"] == "ok"

        delete_user = cloudinary.provisioning.delete_user(cls.user_id)
        assert delete_user["message"] == "ok"

        delete_user_group = cloudinary.provisioning.delete_user_group(
            cls.group_id)
        assert delete_user_group['ok']
Esempio n. 6
0
 def test_cloudinary_account_url_invalid_scheme(self):
     config = account_config()
     cloudinary_account_urls = [
         'CLOUDINARY__ACCOUNT_URL=account://123456789012345:ALKJdjklLJAjhkKJ45hBK92baj3@test',
         'https://*****:*****@test',
         '://123456789012345:ALKJdjklLJAjhkKJ45hBK92baj3@test',
         'https://*****:*****@test?account=foo'
         ' '
     ]
     for cloudinary_account_url in cloudinary_account_urls:
         with self.assertRaises(ValueError):
             parsed_url = config._parse_cloudinary_url(
                 cloudinary_account_url)
             config._setup_from_parsed_url(parsed_url)