Add channel to update check and use new endpoint (#1568)

* Add a channel key to update check and use a new GET based update check endpoint
* Bump `black` version to `19.10b0`
This commit is contained in:
Kevin Chung
2020-07-24 01:59:14 -04:00
committed by GitHub
parent 1e2160bcb6
commit 4d4097a267
5 changed files with 8 additions and 5 deletions

View File

@@ -27,6 +27,7 @@ from CTFd.utils.sessions import CachingSessionInterface
from CTFd.utils.updates import update_check
__version__ = "3.0.0b3"
__channel__ = "oss"
class CTFdRequest(Request):
@@ -209,6 +210,7 @@ def create_app(config="CTFd.config.Config"):
app.db = db
app.VERSION = __version__
app.CHANNEL = __channel__
from CTFd.cache import cache

View File

@@ -50,9 +50,10 @@ def update_check(force=False):
"team_count": Teams.query.count(),
"theme": get_config("ctf_theme"),
"upload_provider": get_app_config("UPLOAD_PROVIDER"),
"channel": app.CHANNEL,
}
check = requests.post(
"https://versioning.ctfd.io/", json=params, timeout=0.1
check = requests.get(
"https://versioning.ctfd.io/check", params=params, timeout=0.1
).json()
except requests.exceptions.RequestException:
pass

View File

@@ -1,7 +1,7 @@
lint:
flake8 --ignore=E402,E501,E712,W503,E203 --exclude=CTFd/uploads CTFd/ migrations/ tests/
yarn lint
black --check --exclude=CTFd/uploads --exclude=node_modules .
black --check --diff --exclude=CTFd/uploads --exclude=node_modules .
prettier --check 'CTFd/themes/**/assets/**/*'
prettier --check '**/*.md'

View File

@@ -18,4 +18,4 @@ isort==4.3.21
flake8-isort==3.0.0
Faker==4.1.0
pipdeptree==0.13.2
black==19.3b0
black==19.10b0

View File

@@ -14,7 +14,7 @@ def test_update_check_is_called():
assert get_config("version_latest") is None
@patch.object(requests, "post")
@patch.object(requests, "get")
def test_update_check_identifies_update(fake_get_request):
"""Update checks properly identify new versions"""
app = create_ctfd()