mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 01:25:16 +00:00
2dff8b9a00
* Apply black formatting * Add auto formatting when committing to master * Update CONTRIBUTING.md re. Black & Prettier
50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
from tests import BaseTestCase
|
|
from redash.models import Organization
|
|
|
|
|
|
class TestOrganizationSettings(BaseTestCase):
|
|
def test_post(self):
|
|
admin = self.factory.create_admin()
|
|
rv = self.make_request(
|
|
"post",
|
|
"/api/settings/organization",
|
|
data={"auth_password_login_enabled": False},
|
|
user=admin,
|
|
)
|
|
self.assertEqual(rv.json["settings"]["auth_password_login_enabled"], False)
|
|
self.assertEqual(
|
|
self.factory.org.settings["settings"]["auth_password_login_enabled"], False
|
|
)
|
|
|
|
rv = self.make_request(
|
|
"post",
|
|
"/api/settings/organization",
|
|
data={"auth_password_login_enabled": True},
|
|
user=admin,
|
|
)
|
|
updated_org = Organization.get_by_slug(self.factory.org.slug)
|
|
self.assertEqual(rv.json["settings"]["auth_password_login_enabled"], True)
|
|
self.assertEqual(
|
|
updated_org.settings["settings"]["auth_password_login_enabled"], True
|
|
)
|
|
|
|
def test_updates_google_apps_domains(self):
|
|
admin = self.factory.create_admin()
|
|
domains = ["example.com"]
|
|
rv = self.make_request(
|
|
"post",
|
|
"/api/settings/organization",
|
|
data={"auth_google_apps_domains": domains},
|
|
user=admin,
|
|
)
|
|
updated_org = Organization.get_by_slug(self.factory.org.slug)
|
|
self.assertEqual(updated_org.google_apps_domains, domains)
|
|
|
|
def test_get_returns_google_appas_domains(self):
|
|
admin = self.factory.create_admin()
|
|
domains = ["example.com"]
|
|
admin.org.settings[Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains
|
|
|
|
rv = self.make_request("get", "/api/settings/organization", user=admin)
|
|
self.assertEqual(rv.json["settings"]["auth_google_apps_domains"], domains)
|