Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mouday committed Nov 5, 2022
1 parent 387980e commit bc8d15b
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 10 deletions.
2 changes: 1 addition & 1 deletion domain_admin/api/cert_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_cert_information():
domain = request.json['domain']

try:
data = cert_util_v2.get_cert_info(domain)
data = cert_util.get_cert_info(domain)
except Exception as e:
data = None

Expand Down
4 changes: 4 additions & 0 deletions domain_admin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def teardown_request(exc):

@app.get('/')
def index():
"""
静态首页
:return:
"""
return send_file('public/index.html')


Expand Down
2 changes: 1 addition & 1 deletion domain_admin/service/domain_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def update_domain_cert_info(row):
info = {}

try:
info = cert_util_v2.get_cert_info(row.domain)
info = cert_util.get_cert_info(row.domain)
connect_status = True
except Exception:
pass
Expand Down
2 changes: 1 addition & 1 deletion domain_admin/utils/cert_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""
@File : cert_util_v2.py
@File : cert_util.py
@Date : 2022-10-22
@Author : Peng Shiyu
Expand Down
2 changes: 1 addition & 1 deletion domain_admin/utils/domain_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def parse_domain(domain):
:param domain:
:return:
"""
ret = re.match('.*?//([a-zA-Z\.0-9]+)/?.*?', domain)
ret = re.match('.*?//([a-zA-Z\\.0-9]+)/?.*?', domain)
if ret:
return ret.groups()[0]
else:
Expand Down
2 changes: 1 addition & 1 deletion domain_admin/utils/flask_ext/flask_app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from collections import Iterator
from typing import Iterator

from flask import Flask
from peewee import ModelSelect, Model
Expand Down
2 changes: 1 addition & 1 deletion domain_admin/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"""
版本号
"""
VERSION = '0.0.15'
VERSION = '0.0.16'
8 changes: 4 additions & 4 deletions requirements/production.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
requests>=2.27.0
Flask==2.0.0
werkzeug>=2.2.2
requests==2.28.1
Flask==2.2.2
werkzeug==2.2.2
Jinja2==3.0.0
Flask-Cors==3.0.10
peewee==3.15.3
python-dateutil==2.8.2
gunicorn==20.1.0
gevent==21.12.0
apscheduler>=3.9.1
apscheduler==3.9.1
PyJWT>=2.5.0
bcrypt>=4.0.0
python-dotenv>=0.21.0
Expand Down
6 changes: 6 additions & 0 deletions tests/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
"""
@File : __init__.py.py
@Date : 2022-11-05
@Author : Peng Shiyu
"""
15 changes: 15 additions & 0 deletions tests/api/auth_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
"""
@File : auth_api.py
@Date : 2022-11-05
@Author : Peng Shiyu
"""


def test_login(client):
response = client.post('/api/login', json={
'username': 'admin',
'password': '123456'
})

assert response.json['code'] == 0
28 changes: 28 additions & 0 deletions tests/api/test_cert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
"""
@File : test_cert.py
@Date : 2022-11-05
@Author : Peng Shiyu
"""


def test_get_cert_information_not_login(client):
response = client.post('/api/getCertInformation')
assert response.json['code'] == 401


def test_get_cert_information_not_params(client, token):
response = client.post(
path='/api/getCertInformation',
headers={'x-token': token}
)

assert response.json['code'] == -1


def test_get_cert_information(client, token):
response = client.post('/api/getCertInformation', json={
'domain': 'www.baidu.com'
}, headers={'x-token': token})

assert response.json['code'] == 0
11 changes: 11 additions & 0 deletions tests/api/test_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
"""
@File : test_demo.py
@Date : 2022-11-05
@Author : Peng Shiyu
"""


def test_index(client):
response = client.get('/')
assert 'id="app"' in response.text
32 changes: 32 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
"""
@File : conftest.py
@Date : 2022-11-05
@Author : Peng Shiyu
"""
import pytest
from flask.testing import FlaskClient

from domain_admin.main import app


@pytest.fixture()
def client() -> FlaskClient:
app.config.update({
"TESTING": True,
})

with app.app_context():
client = app.test_client()

return client


@pytest.fixture()
def token(client) -> str:
response = client.post('/api/login', json={
'username': 'admin',
'password': '123456'
})

return response.json['data']['token']

0 comments on commit bc8d15b

Please sign in to comment.