Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: agdsn/sipa
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9bb2abbd2f40eba7a71352dbfafa7c882807ff36^
Choose a base ref
...
head repository: agdsn/sipa
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.2
Choose a head ref

Commits on Jan 25, 2016

  1. Return KiB Values in the model

    - Add a template filter and use it for the gauge
    - Return KiB in implemented models
    - Fix the tests accordingly
    
    Fix #157
    lukasjuhrich committed Jan 25, 2016
    Copy the full SHA
    9bb2abb View commit details

Commits on Feb 12, 2016

  1. Copy the full SHA
    e4e4d71 View commit details
  2. Copy the full SHA
    534ce04 View commit details
  3. Tiny reformatting in message composition

    No implementation change
    lukasjuhrich committed Feb 12, 2016
    Copy the full SHA
    23e6f47 View commit details
  4. Update translations

    lukasjuhrich committed Feb 12, 2016
    Copy the full SHA
    a8169e5 View commit details
  5. Copy the full SHA
    e25846f View commit details
  6. Create a manage.py, add Flask-Script package

    The `manage.py` contains a generic `test` method.
    
    Ref #189
    Ref #188
    lukasjuhrich committed Feb 12, 2016
    Copy the full SHA
    05ca3f3 View commit details
  7. Add nosetest support if available

    Ref #189
    lukasjuhrich committed Feb 12, 2016
    Copy the full SHA
    1c73195 View commit details
  8. Copy the full SHA
    6b9c1f6 View commit details
  9. Copy the full SHA
    3380cb7 View commit details

Commits on Feb 13, 2016

  1. Disable SQLALCHEMY_TRACK_MODIFICATIONS

    This is just to avoid the warning.  Track modifications don't affect us
    anyway, since they only apply when one wants to make use of tracking
    changes in the model.  It will in future releases be disabled by default
    according to the warning.
    lukasjuhrich committed Feb 13, 2016
    Copy the full SHA
    87b285a View commit details
  2. Use a dictConfig instead of the old-style ini

    Adding an extra config in the ini style is still supported, but will be
    replaced by something better soon.
    
    Also, test `location_log_config` for None, because `isfile` does not
    accept `None` as a path.
    
    Refs #190
    lukasjuhrich committed Feb 13, 2016
    Copy the full SHA
    1e521b9 View commit details

Commits on Feb 14, 2016

  1. Configure sentry before the logging config

    Sentry is now being initialized before the default and additional log
    configs are applied.  This has the advantage that in the near future,
    when an additional `dict` config can be provided, such handlers can be
    added by will.
    
    Currently, only one `Sentry` instance is assumed, located at
    `app.extensions['sentry']`.  Consequently, every `SentryHandler`
    returned by the handler-creating callable is linked to the latter.
    
    Making this possible required a small patch.  See the docstring of
    `replace_empty_handler_callables`.
    
    Usage in a dict logging config: See `sipa.defaults.DEFAULT_CONFIG`.
    
    Refs #190
    lukasjuhrich committed Feb 14, 2016
    Copy the full SHA
    35ce9e2 View commit details
  2. Copy the full SHA
    486aa64 View commit details
  3. Use debug instead of info

    This is a message concerning the initialization of the app.  I think
    this better fits into the `DEBUG` layer.
    lukasjuhrich committed Feb 14, 2016
    Copy the full SHA
    e34db3f View commit details
  4. Copy the full SHA
    500cadf View commit details
  5. Add trailing comma

    lukasjuhrich committed Feb 14, 2016
    Copy the full SHA
    d09ec9e View commit details
  6. Copy the full SHA
    9392783 View commit details
  7. Copy the full SHA
    57ed7ce View commit details
  8. Copy the full SHA
    235b832 View commit details

Commits on Feb 20, 2016

  1. Copy the full SHA
    623f945 View commit details
  2. Copy the full SHA
    f68488e View commit details
  3. Copy the full SHA
    9b60121 View commit details

Commits on Feb 21, 2016

  1. Add json testing && improve api mocking

    Since we don't actually care about the implementation (“was `.json`
    called?”, “Was a `ValueError` catched?”, …), we don't need to mock the
    `Response` object and all of its functions.
    
    The better approach is to let the mocked `get`-function return an actual
    `Response` object, and setting the binary content (`content` is a
    property, thus `_content` is set).
    
    Now, the test only has to verify whether the binary represantation of a
    json-dump of a dict is being read into the same dict again.
    lukasjuhrich committed Feb 21, 2016
    Copy the full SHA
    fec450e View commit details
  2. Copy the full SHA
    7514aad View commit details
  3. Explicitly test if 'post' was given for api call

    It is more consequent to check explicitly for 'get' and 'post' as the
    `method`-argument for `do_api_call`.
    
    Also, add a test for the invalidity of something else.
    lukasjuhrich committed Feb 21, 2016
    Copy the full SHA
    3b6626f View commit details
  4. Copy the full SHA
    273ba72 View commit details
  5. Move model tests to own package tests/model

    Also, put the `gerok` and `sample` tests into their own module.
    lukasjuhrich committed Feb 21, 2016
    Copy the full SHA
    cee3c27 View commit details
  6. Copy the full SHA
    773615b View commit details
  7. Use set, not list for output comparison

    Using `list` would cause (under certain circumstances) the test to fail,
    just because the position of the returned elements in the list is
    different.  Obviously, this is not what we want to test.
    lukasjuhrich committed Feb 21, 2016
    Copy the full SHA
    c474238 View commit details
  8. Copy the full SHA
    8906546 View commit details
  9. Update the wrapper in active_property

    Forgetting this somehow bricked the abc-mechanism, which is not
    surprising, since not using `functools.wraps` for a decorator is
    foolish.
    
    SPOILER ALERT: I'm to blame.
    lukasjuhrich committed Feb 21, 2016
    Copy the full SHA
    92c15f6 View commit details
  10. Delete unused user_id property

    What this ought to do was exactly the same as what `id` does.  The
    difference is: one is being used, the other – not so much.
    
    This fixes the tests that got `broken` by actually fixing the
    `active_property` decorator in the previous commit.
    
    Lucky me.
    lukasjuhrich committed Feb 21, 2016
    Copy the full SHA
    57fa9c4 View commit details
  11. Copy the full SHA
    5721e08 View commit details

Commits on Feb 22, 2016

  1. Add first test && structure for gerok.User tests

    - Add the test structure, i.e. `TestGerokUser` class with example user,
      `User` comparison method and api mock
    
    - Add test testing an explicit creation via `__init__`
    lukasjuhrich committed Feb 22, 2016
    Copy the full SHA
    b612bd9 View commit details
  2. Add test for gerok.User.from_ip, improve tests

    - Update the fake API to correctly parse the given query string
      (This was to add `find?ip={}` query functionality)
    
    - Test user creation via `User.from_ip`
    
    - Rename `id` to `user_id` where necessary (id is a builtin function)
    lukasjuhrich committed Feb 22, 2016
    Copy the full SHA
    85f9345 View commit details
  3. Fix gerok.User.from_ip and test for name

    - In `User.from_ip`, the constructor `cls()` has been called with
      a *completely different* signature, which last commit's test showed.
    
    - In the same run, cache the name on explicit user creation, and include
      `realname` in the tests.
    lukasjuhrich committed Feb 22, 2016
    Copy the full SHA
    eb89209 View commit details
  4. Allow generic user_data in gerok.User.__init__

    It makes far more sense to pass the whole (and often used) `user_data`
    dict instead of the isolated parameters `name` and `mail`.
    lukasjuhrich committed Feb 22, 2016
    Copy the full SHA
    f1b50d7 View commit details
  5. Copy the full SHA
    a8423d6 View commit details
  6. Copy the full SHA
    f536ea7 View commit details

Commits on Feb 23, 2016

  1. Allow empty redirection mail address

    In the gerok module, the `mail` field of the API's `userdata` JSON-dict
    is supposed to be the redirection mail address.  Thus, if it is empty,
    the `user.mail` property should contain the builtin mail address of the
    gerok module.
    
    The tests were extended so this usecase is in `assert_userdata_passed`.
    lukasjuhrich committed Feb 23, 2016
    Copy the full SHA
    6692e1b View commit details
  2. Add space between 1024if

    Funnily, the inline `if` statement got parsed correctly.
    lukasjuhrich committed Feb 23, 2016
    Copy the full SHA
    2c40b56 View commit details
  3. Copy the full SHA
    26248a6 View commit details
  4. Test get constructor && improve fake api

    The fake api got extended by the used `find?login=` functionality, a
    corresponding test for `user.get()` has been added.
    lukasjuhrich committed Feb 23, 2016
    Copy the full SHA
    3fd9322 View commit details
  5. Add authentication tests

    lukasjuhrich committed Feb 23, 2016
    Copy the full SHA
    4a537b2 View commit details
  6. Add Test for from_ip with wrong ips

    This includes:
    
    - a fix in the `userData` comparisons asking whether nothing came
      back (`if not` is correct for the empty string, `do_api_call` never
      returns `None`)
    
    - a fix in the fake api concerning not being given an existent IP
    
    - a test with a few foreign IPs checking for `AnonymousUserMixin`.
    lukasjuhrich committed Feb 23, 2016
    Copy the full SHA
    54ed4d9 View commit details
  7. Add testing support for credit property

    This is mostly implementation in the `fake_api`, the test itself is just
    an `AssertEqual`.
    lukasjuhrich committed Feb 23, 2016
    Copy the full SHA
    5a155f4 View commit details
  8. Test traffic data passing

    Extensively test correct availability of traffic data in `gerok.User`.
    lukasjuhrich committed Feb 23, 2016
    Copy the full SHA
    a560636 View commit details
  9. Intelligently create sample user_data

    The `user_data` being used in the `TestGerokUser` Case is now created as
    a mixture of the cartesian product of certain edgecases (combinations of
    missing traffic entries, 0-2 hosts) and an iterating, and thus unique,
    part contributing attributes like `name` and `password`.
    lukasjuhrich committed Feb 23, 2016
    Copy the full SHA
    d5e80fd View commit details
  10. Move assertions to specific tests

    The assertions concerning the traffic entries belong in their own test.
    lukasjuhrich committed Feb 23, 2016
    Copy the full SHA
    3218c53 View commit details
Showing with 3,772 additions and 698 deletions.
  1. +6 −0 .coveragerc
  2. +27 −0 .github/CONTRIBUTING.md
  3. +10 −0 .github/PULL_REQUEST_TEMPLATE.md
  4. +12 −0 .travis.yml
  5. +0 −37 Dockerfile
  6. +1 −0 Dockerfile
  7. +58 −0 README.md
  8. +39 −0 build/Dockerfile
  9. +27 −0 build/development.yml
  10. +19 −0 build/install_requirements.py
  11. +17 −0 build/requirements/requirements.txt
  12. +4 −0 build/requirements/requirements_testing.txt
  13. +12 −0 build/testing.yml
  14. +0 −21 development.yml
  15. +1 −1 docker-compose.yml
  16. 0 sipa/default_log_config → example/log_config.ini
  17. +93 −0 manage.py
  18. +0 −15 requirements.txt
  19. +1 −0 requirements.txt
  20. +13 −0 run_tests.sh
  21. +2 −0 sipa.py
  22. +2 −2 sipa/__init__.py
  23. +2 −2 sipa/base.py
  24. +1 −0 sipa/blueprints/__init__.py
  25. +19 −22 sipa/blueprints/generic.py
  26. +42 −0 sipa/blueprints/hooks.py
  27. +2 −2 sipa/blueprints/usersuite.py
  28. 0 sipa/config/__init__.py
  29. +69 −0 sipa/config/default.py
  30. +86 −0 sipa/config/example.py
  31. +0 −82 sipa/default_config.py
  32. +57 −0 sipa/defaults.py
  33. +6 −6 sipa/flatpages.py
  34. +10 −4 sipa/forms.py
  35. +63 −41 sipa/initialization.py
  36. +2 −2 sipa/model/__init__.py
  37. +1 −1 sipa/model/datasource.py
  38. +2 −7 sipa/model/default/__init__.py
  39. +44 −33 sipa/model/gerok/user.py
  40. +18 −5 sipa/model/property.py
  41. +3 −3 sipa/model/sample/user.py
  42. +18 −14 sipa/model/wu/__init__.py
  43. +44 −29 sipa/model/wu/database_utils.py
  44. +76 −0 sipa/model/wu/factories.py
  45. +2 −1 sipa/model/wu/ldap_utils.py
  46. +4 −1 sipa/model/wu/schema.py
  47. +34 −27 sipa/model/wu/user.py
  48. +0 −16 sipa/model/zeu/__init__.py
  49. +147 −0 sipa/static/css/bootstrap-social.css
  50. +4 −0 sipa/static/css/font-awesome.min.css
  51. BIN sipa/static/fonts/FontAwesome.otf
  52. BIN sipa/static/fonts/fontawesome-webfont.eot
  53. +685 −0 sipa/static/fonts/fontawesome-webfont.svg
  54. BIN sipa/static/fonts/fontawesome-webfont.ttf
  55. BIN sipa/static/fonts/fontawesome-webfont.woff
  56. BIN sipa/static/fonts/fontawesome-webfont.woff2
  57. +323 −89 sipa/static/js/pygal-tooltips.js
  58. +28 −1 sipa/templates/base.html
  59. BIN sipa/translations/de/LC_MESSAGES/messages.mo
  60. +43 −35 sipa/translations/de/LC_MESSAGES/messages.po
  61. BIN sipa/translations/en/LC_MESSAGES/messages.mo
  62. +45 −37 sipa/translations/en/LC_MESSAGES/messages.po
  63. +39 −0 sipa/units.py
  64. +46 −4 sipa/utils/__init__.py
  65. +6 −3 sipa/utils/bootstraped_tables.py
  66. +31 −5 sipa/utils/git_utils.py
  67. +32 −8 sipa/utils/graph_utils.py
  68. +4 −2 sipa/utils/link_patch.py
  69. +4 −4 sipa/utils/mail_utils.py
  70. 0 tests/blueprints/__init__.py
  71. +65 −0 tests/blueprints/test_hooks.py
  72. 0 tests/model/__init__.py
  73. +415 −0 tests/model/test_gerok.py
  74. +5 −105 tests/{ → model}/test_model.py
  75. +100 −0 tests/model/test_sample.py
  76. +451 −0 tests/model/test_wu.py
  77. +10 −4 tests/prepare.py
  78. +199 −0 tests/test_git.py
  79. +0 −26 tests/test_model_wu.py
  80. +61 −0 tests/test_units.py
  81. +76 −1 tests/test_utils.py
  82. +4 −0 tox.ini
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[run]
# Don't store coverage in `.coverage` to avoid permission conflicts.
# Although reading / writing may be alright, `coverage` tries to
# delete `.coverage`, which doesn't work at all when the dir is
# mounted.
data_file=/tmp/sipa_coverage
27 changes: 27 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Contributing

## Style Guidelines

Please stay conform to PEP8. The only thing not so important is the
line length, but trying too keep it <90 chars is good practise.

## Testing

You should _always_ test your code before you commit – at the very
least before you decide to make a PR.

Also, if you introduce new code, include at least some basic tests.
Falling behind in coverage because of laziness is bad, really bad.

Similar for bugs: When fixing a bug, introduce a test case for it –
and verify it fails before the fix has been introduced. You might
want to use the
[@expectedFailure](https://docs.python.org/3.5/library/unittest.html#unittest.expectedFailure)
decorator and create a separate commit introducing the test before the
fix – but these details are not so important.


## Pushing

Don't push to develop directly, _always_ create a PR! Only then the
CI can verify your code.
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
You're opening a pull request? __Awesome!__

Please make sure though you did the following (tick off everything you
already did):

- [ ] Run the tests and see them pass
- [ ] Rebase your branch on top of `develop`
- [ ] Include tests for features you introduced / bugs you fixed

This issue fixes #
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: python
python:
- "3.5"
install:
- "pip install -r ./build/requirements/requirements.txt"
- "pip install Flask-Testing coverage pep8 rednose"
# nose is already installed by default.
cache:
- pip
script:
- "python manage.py test"
- "pep8 ."
37 changes: 0 additions & 37 deletions Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions Dockerfile
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/agdsn/sipa.svg?branch=develop)](https://travis-ci.org/agdsn/sipa)

SIPA - Supreme Information Providing Application
================================================

@@ -19,6 +21,36 @@ Please note that SIPA has been built to fit our specific purposes. This means
that there will be features you probably won't need, such as the traffic
monitoring or splitting the login process into certain divisions.


How can I run Sipa?
-------------------

As a general note, you should have `docker` and `docker-compose`
installed. Just using python and e.g. a virtualenv is possible, but
discouraged.

The simplest method is to run `docker-compose up -d`.

This should automatically set up an nginx container on port 80
providing `/sipa` and `/sipa_debug`, which are two containers of sipa,
the first running on uwsgi, and the second directly using `sipa.py`.

If this does not work for you see “Running on Docker” below for a
manual (i.e. not docker-compose-based) container setup.


How can I run the tests?
------------------------

Run `./run_tests.sh`. If you run it for the first time, this should
build the `sipa_testing` docker image, which may take a few minutes.

Please note that, although the `sipa` folder is mounted into the
container, you will have to recreate the docker image if the
requirements changed. You can just let the script do this by removing
the image with `docker rmi sipa_testing`.


Running on Docker
-----------------

@@ -51,6 +83,32 @@ docker run --name sipa -p 5000:5000 -d sipa python sipa.py --exposed
If you want to use sipa for development, adding `--debug` after `sipa.py` and
mounting your sipa folder using `-v <path>:/home/sipa/sipa` is recommended.

## Configuration ##

### Environment variables ###

The default config (`sipa.default_config`) reads environment variables
for the most cases.

### Local Python config file ###

If one prefers to write configuration into a file locally, sipa reads
`/config.py`. If the environment variable `SIPA_CONFIG_FILE` is set,
its path is taken instead.

### Logging ###

In order to provide an additional logfile, set the app's `LOG_CONFIG`
variable in your local configuration file.

It has to be set to a dict usable by `dictConfig()`. For further
documentation, see [the python docs](https://docs.python.org/3/howto/logging-cookbook.html#an-example-dictionary-based-configuration).

Also, you might want to look into `sipa.defaults.DEFAULT_CONFIG` for the current structure.

Keep in mind you don't need to rewrite the whole default configuration
every time, since you can include `'incremental': True` in said dict.


Required format for the markdown files
--------------------------------------
39 changes: 39 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM python:latest
MAINTAINER Lukas Juhrich der Große <lukasjuhrich@wh2.tu-dresden.de>


ENV DEBIAN_FRONTEND=noninteractive \
LC_ALL=C

RUN apt-get update && apt-get install -y --no-install-recommends \
libldap2-dev \
libsasl2-dev \
libmysqlclient-dev \
libxml2-dev \
libxslt1-dev \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN pip install --upgrade pip

RUN pip install uwsgi

RUN addgroup --gid 9999 sipa && \
adduser --uid 9999 --gid 9999 --disabled-password --gecos "Application" sipa

RUN mkdir /home/sipa/sipa
WORKDIR /home/sipa/sipa

ADD ./build /home/sipa/sipa/build/
ARG additional_requirements
RUN ./build/install_requirements.py $additional_requirements

ADD . /home/sipa/sipa
RUN chown -R sipa:sipa /home/sipa/sipa

EXPOSE 5000

USER sipa

CMD ["uwsgi", "--ini", "uwsgi.ini"]
27 changes: 27 additions & 0 deletions build/development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '2'
services:
sipa_debug:
build:
context: ..
dockerfile: build/Dockerfile
command: python sipa.py --debug --exposed
volumes:
- ./:/home/sipa/sipa
sipa:
build:
context: ..
dockerfile: build/Dockerfile
environment:
- SIPA_UWSGI_PREFIX=/sipa
volumes:
- ./:/home/sipa/sipa
nginx:
image: nginx
volumes:
- ./example/nginx.conf:/etc/nginx/nginx.conf:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
ports:
- "80:80"
links:
- sipa
- sipa_debug
19 changes: 19 additions & 0 deletions build/install_requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python
import sys
from os.path import join

import pip


DEFAULT_REQUIREMENTS = 'requirements.txt'
# this script expect to be started from `sipa/`
PATH = './build/requirements/'


def main():
files_to_install = {DEFAULT_REQUIREMENTS, *sys.argv[1:]}
for filename in files_to_install:
pip.main(['install', '-r', join(PATH, filename)])

if __name__ == '__main__':
main()
17 changes: 17 additions & 0 deletions build/requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
flask==0.10.1
Flask-Login==0.3.0
Babel==2.0
Flask-Babel==0.9
Flask-Script==2.0.3
SQLAlchemy==1.0.8
Flask-SQLAlchemy==2.1
raven==5.7.1
ldap3==0.9.9
requests==2.7.0
Flask-FlatPages==0.6
pygal==2.0.6
GitPython==1.0.1
Flask-WTF==0.12
PyMySQL==0.6.6
blinker==1.4
factory-boy==2.6.1
4 changes: 4 additions & 0 deletions build/requirements/requirements_testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage==4.0.3
Flask-Testing==0.4.2
nose==1.3.7
rednose==0.4.3
12 changes: 12 additions & 0 deletions build/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '2'
services:
sipa_testing:
build:
context: ..
dockerfile: build/Dockerfile
args:
additional_requirements: requirements_testing.txt
image: sipa_testing
command: python manage.py test
volumes:
- ./:/home/sipa/sipa
21 changes: 0 additions & 21 deletions development.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
File renamed without changes.
Loading