Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into web-api-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmartin committed May 13, 2019
2 parents ce0a876 + 5ae46ee commit 5af503f
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -18,6 +18,8 @@ script: tox

matrix:
include:
- python: 3.7
env: TOXENV=py37
- python: 3.7
env: TOXENV=flake8
- python: 3.7
Expand Down
3 changes: 3 additions & 0 deletions README.md
@@ -1,5 +1,8 @@
# picoCTF

[![Build Status](https://travis-ci.com/picoCTF/picoCTF.svg?branch=master)](https://travis-ci.com/picoCTF/picoCTF)
[![codecov](https://codecov.io/gh/picoCTF/picoCTF/branch/master/graph/badge.svg)](https://codecov.io/gh/picoCTF/picoCTF)

The picoCTF platform is the infrastructure which is used to run
[picoCTF](https://picoctf.com/).

Expand Down
4 changes: 4 additions & 0 deletions picoCTF-shell/requirements.txt
@@ -0,0 +1,4 @@
coloredlogs==10.0
Jinja2==2.10.1
spur==0.3.20
voluptuous==0.11.1
Empty file added picoCTF-shell/tests/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions picoCTF-shell/tests/test_problems.py
@@ -1,3 +1,4 @@
import pytest
from os.path import dirname, join, realpath

import hacksport.deploy
Expand All @@ -9,6 +10,7 @@
hacksport.deploy.deploy_config = default_config


@pytest.mark.skip("Broken tests/not working")
class TestProblems:
"""
Regression tests for compiled problems.
Expand Down
Empty file.
14 changes: 14 additions & 0 deletions picoCTF-shell/tests/unit/test_config.py
@@ -0,0 +1,14 @@
import pytest
from shell_manager import config


@pytest.mark.parametrize("port_range, expected_string", [
([dict(start=0, end=65535)], "[0-65535]"),
([dict(start=1000, end=1000)], "[1000]"),
([dict(start=1000, end=1000), dict(start=1000, end=10000)],
"[1000, 1000-10000]"),
])
def test_port_range_to_str(port_range, expected_string):
"""Test strings are correctly created from port range lists."""
returned_string = config.banned_ports_to_str(port_range)
assert expected_string == returned_string
26 changes: 26 additions & 0 deletions picoCTF-shell/tests/unit/test_util.py
@@ -0,0 +1,26 @@
import pytest
from shell_manager import util


@pytest.mark.parametrize("problem_name, expected_name", [
("Test Problem", "test-problem"),
("01234", "p01234"),
("1 2 spaces", "p1-2--spaces"),
])
def test_problem_name_sanitization(problem_name, expected_name):
"""Test valid problem names are correctly sanitized."""
sanitized_name = util.sanitize_name(problem_name)
assert expected_name == sanitized_name


@pytest.mark.parametrize("problem_name", [
"",
None,
])
def test_invalid_prob_name_sanitization(problem_name):
"""Test invalid problem names raise an exception during sanitization."""
with pytest.raises(Exception) as excep_info:
util.sanitize_name(problem_name)
assert "Can not sanitize an empty field" in str(excep_info.value)


21 changes: 18 additions & 3 deletions tox.ini
@@ -1,13 +1,28 @@
[tox]
# don't perform package operation and install it to virtual env
skipsdist=True
envlist = flake8, bandit
envlist = py37, flake8, bandit


[testenv]
description = run tests for picoCTF-shell
passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_*
basepython = python3
changedir = picoCTF-shell
deps =
pytest
pytest-cov
codecov>=1.4.0
-rpicoCTF-shell/requirements.txt
commands =
pytest --cov=hacksport/ --cov-branch --cov=shell_manager/
codecov -e TOXENV


[testenv:flake8]
description = run flake8 with isort to check code and docstring style
basepython = python3
skip_install = true
changedir = {toxinidir}
deps =
flake8
flake8-isort
Expand All @@ -19,7 +34,7 @@ commands =
[testenv:bandit]
description = run bandit security linter for picoCTF with {basepython}
basepython = python3
skip_install = true
changedir = {toxinidir}
deps =
bandit
commands =
Expand Down

0 comments on commit 5af503f

Please sign in to comment.