-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1317 from longguikeji/feature-402
feat: 🎸 增加一些测试代码
- Loading branch information
Showing
14 changed files
with
632 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from tests import TestCase | ||
|
||
class TestAuthApi(TestCase): | ||
|
||
def test_auth(self): | ||
''' | ||
认证 | ||
''' | ||
url = '/api/v1/tenant/{}/auth/?event_tag=com.longgui.auth.factor.password.auth'.format(self.tenant.id) | ||
body = { | ||
"username":"admin", | ||
"password":"admin", | ||
"config_id":"70f8d39e-30cc-40de-8a70-ec6495c21e84" | ||
} | ||
resp = self.client.post(url, body ,content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_reset_passowrd(self): | ||
''' | ||
重置密码 | ||
''' | ||
url = '/api/v1/tenant/{}/reset_password/?event_tag=com.longgui.auth.factor.password.auth'.format(self.tenant.id) | ||
body = { | ||
"username":"admin", | ||
"password":"admin", | ||
"config_id":"70f8d39e-30cc-40de-8a70-ec6495c21e84" | ||
} | ||
resp = self.client.post(url, body ,content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
from tests import TestCase | ||
|
||
class TestAuthFactorApi(TestCase): | ||
|
||
def test_list_auth_factors(self): | ||
''' | ||
认证因素列表 | ||
''' | ||
url = '/api/v1/tenant/{}/auth_factors/'.format(self.tenant.id) | ||
resp = self.client.get(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_get_auth_factor(self): | ||
''' | ||
获取认证因素 | ||
''' | ||
url = '/api/v1/tenant/{}/auth_factors/{}/'.format(self.tenant.id, self.auth_factor.id) | ||
resp = self.client.get(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_create_auth_factor(self): | ||
''' | ||
创建认证因素 | ||
''' | ||
url = '/api/v1/tenant/{}/auth_factors/'.format(self.tenant.id) | ||
body = { | ||
"type":"password", | ||
"config":{ | ||
"login_enabled":True, | ||
"register_enabled":True, | ||
"login_enabled_field_names":[ | ||
{ | ||
"key":None | ||
} | ||
], | ||
"register_enabled_field_names":[ | ||
{ | ||
"key":None | ||
} | ||
], | ||
"is_apply":False, | ||
"regular":"", | ||
"title":"" | ||
}, | ||
"name":"defaultpass", | ||
"package":"com.longgui.auth.factor.password" | ||
} | ||
resp = self.client.post(url, body, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_update_auth_factor(self): | ||
''' | ||
编辑认证因素 | ||
''' | ||
url = '/api/v1/tenant/{}/auth_factors/{}/'.format(self.tenant.id, self.auth_factor.id) | ||
body = { | ||
"type":"password", | ||
"config":{ | ||
"login_enabled":True, | ||
"register_enabled":True, | ||
"login_enabled_field_names":[ | ||
{ | ||
"key":"username" | ||
} | ||
], | ||
"register_enabled_field_names":[ | ||
{ | ||
"key":"username" | ||
} | ||
], | ||
"is_apply":False, | ||
"regular":"", | ||
"title":"" | ||
}, | ||
"name":"default", | ||
"package":"com.longgui.auth.factor.password" | ||
} | ||
resp = self.client.post(url, body, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_delete_auth_factor(self): | ||
''' | ||
删除认证因素 | ||
''' | ||
url = '/api/v1/tenant/{}/auth_factors/{}/'.format(self.tenant.id, self.auth_factor.id) | ||
resp = self.client.delete(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
from tests import TestCase | ||
|
||
class TestAuthRulesApi(TestCase): | ||
|
||
def test_list_auth_rules(self): | ||
''' | ||
认证规则列表 | ||
''' | ||
url = '/api/v1/tenant/{}/auth_rules/'.format(self.tenant.id) | ||
resp = self.client.get(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_get_auth_rule(self): | ||
''' | ||
获取认证规则 | ||
''' | ||
url = '/api/v1/tenant/{}/auth_rules/{}/'.format(self.tenant.id, self.auth_rules.id) | ||
resp = self.client.get(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_create_auth_rule(self): | ||
''' | ||
创建认证规则 | ||
''' | ||
url = '/api/v1/tenant/{}/auth_rules/'.format(self.tenant.id) | ||
body = { | ||
"config":{ | ||
"main_auth_factor":{ | ||
"id":"70f8d39e30cc40de8a70ec6495c21e84", | ||
"name":"default", | ||
"package":"com.longgui.auth.factor.password" | ||
}, | ||
"try_times":3, | ||
"second_auth_factor":{ | ||
"id":"7316fc337547450aa4d4038567949ec2", | ||
"name":"图形验证码", | ||
"package":"com.longgui.auth.factor.authcode" | ||
}, | ||
"expired":30 | ||
}, | ||
"name":"认证规则:登录失败三次启用图形验证码", | ||
"type":"retry_times", | ||
"package":"com.longgui.authrule.retrytimes" | ||
} | ||
resp = self.client.post(url, body, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_update_auth_rule(self): | ||
''' | ||
编辑认证规则 | ||
''' | ||
url = '/api/v1/tenant/{}/auth_rules/{}/'.format(self.tenant.id, self.auth_rules.id) | ||
|
||
body = { | ||
"config":{ | ||
"main_auth_factor":{ | ||
"id":"70f8d39e30cc40de8a70ec6495c21e84", | ||
"name":"default", | ||
"package":"com.longgui.auth.factor.password" | ||
}, | ||
"try_times":3, | ||
"second_auth_factor":{ | ||
"id":"7316fc337547450aa4d4038567949ec2", | ||
"name":"图形验证码", | ||
"package":"com.longgui.auth.factor.authcode" | ||
}, | ||
"expired":30 | ||
}, | ||
"name":"认证规则:登录失败三次启用图形验证码", | ||
"type":"retry_times", | ||
"package":"com.longgui.authrule.retrytimes" | ||
} | ||
resp = self.client.post(url, body, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_delete_auth_rule(self): | ||
''' | ||
删除认证规则 | ||
''' | ||
url = '/api/v1/tenant/{}/auth_rules/{}/'.format(self.tenant.id, self.auth_rules.id) | ||
resp = self.client.delete(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from tests import TestCase | ||
|
||
class TestAutoAuthApi(TestCase): | ||
|
||
def test_list_auto_auths(self): | ||
''' | ||
自动认证列表 | ||
''' | ||
url = '/api/v1/tenant/{}/auto_auths/'.format(self.tenant.id) | ||
resp = self.client.get(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_get_auto_auth(self): | ||
''' | ||
获取自动认证 | ||
''' | ||
url = '/api/v1/tenant/{}/auto_auths/{}/'.format(self.tenant.id, self.auto_auth.id) | ||
resp = self.client.get(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_create_auto_auth(self): | ||
''' | ||
创建应用 | ||
''' | ||
url = '/api/v1/tenant/{}/auto_auths/'.format(self.tenant.id) | ||
body = { | ||
"config":{ | ||
"service_principal":"http://localhost:8001" | ||
}, | ||
"name":"test认证", | ||
"type":"kerberos", | ||
"package":"com.longgui.auto.auth.kerberos" | ||
} | ||
resp = self.client.post(url, body ,content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_update_auto_auth(self): | ||
''' | ||
编辑自动认证 | ||
''' | ||
url = '/api/v1/tenant/{}/auto_auths/{}/'.format(self.tenant.id, self.auto_auth.id) | ||
body = { | ||
"config":{ | ||
"service_principal":"http://localhost:8001" | ||
}, | ||
"name":"test认证", | ||
"type":"kerberos", | ||
"package":"com.longgui.auto.auth.kerberos" | ||
} | ||
resp = self.client.put(url, body ,content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_delete_auto_auth(self): | ||
''' | ||
删除自动认证 | ||
''' | ||
url = '/api/v1/tenant/{}/auto_auths/{}/'.format(self.tenant.id, self.auto_auth.id) | ||
resp = self.client.delete(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from tests import TestCase | ||
|
||
class TestBiSystemApi(TestCase): | ||
|
||
def test_list_bi_systems(self): | ||
''' | ||
BI系统列表 | ||
''' | ||
url = '/api/v1/tenant/{}/bi_systems/'.format(self.tenant.id) | ||
resp = self.client.get(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from tests import TestCase | ||
|
||
class TestBindSaasApi(TestCase): | ||
|
||
def test_get_bind_saas(self): | ||
''' | ||
查询 saas 绑定信息 | ||
''' | ||
url = '/api/v1/tenant/{}/bind_saas/'.format(self.tenant.id) | ||
resp = self.client.get(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_get_bind_saas_slug(self): | ||
''' | ||
查询 saas slug 绑定信息 | ||
''' | ||
url = '/api/v1/tenant/{}/bind_saas/slug/'.format(self.tenant.id) | ||
resp = self.client.get(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) | ||
|
||
def test_get_bind_saas_info(self): | ||
''' | ||
查询 saas info 绑定信息 | ||
''' | ||
url = '/api/v1/tenant/{}/bind_saas/info/'.format(self.tenant.id) | ||
resp = self.client.get(url, content_type='application/json') | ||
self.assertEqual(resp.status_code, 200, resp.content.decode()) |
Oops, something went wrong.