Commit Graph

31 Commits

Author SHA1 Message Date
Min RK
512bbae5cb handle and test a few unlikely cases when Spawners reuse tokens
- test that .will_resume preserves tokens (worked, but wasn't tested)

If a Spawner reuses a token, validate it in the db:

- verify that it's in the db
- if it doesn't map onto the right user, revoke the token
- if it's not in the db, insert it as a user-provided token

The most likely case is prior unclean shutdown of something like DockerSpawner,
where a spawn failed and thus the token was revoked,
but the container was in fact created.
2017-08-17 17:29:33 +02:00
Min RK
e6ce468301 set Spawner.server directly
avoids Spawner.server property looking up on the ORM every time,
which is expensive and we want to check `Spawner.server is None` often.
2017-08-03 09:59:01 +02:00
Matthias Bussonnier
feae3eacb1 Try enforcing methods overwrite at import time.
Currently Spawners need to overwrite start, stop, poll. When this is not
done, it will fail at runtime.

This replicate this check at class definition time, meaning that
potential errors will be caught way earlier. It also have not runtime
cost as the check is a class definition time (ie often import time).

This takes only effect on Python 3.6+ which introduce __init_subclass__,
we could do it with metaclasses, but that's might be too complicated.

If one want to create a class the avoid these restriction they can
overwrite __init_subclass__ and not call the super() method.
2017-07-28 12:05:18 -07:00
Min RK
9e8b6503a0 use gen_test in place of IOLoop.run_sync
even where not strictly required

for consistency, now that we are using gen_test on the main app tests
2017-07-27 11:29:58 +02:00
Min RK
91d042f6f3 get the rest of tests running without threads
all tests pass!
2017-07-27 11:29:58 +02:00
Min RK
382a7121e1 further clear up named servers
- use spawner.server instead of user.server
- user.running, proxy_spec are methods that take spawner names
2017-07-20 16:54:17 +02:00
Min RK
a2e94b8493 create Spawners table
for named servers

removes User.servers
2017-07-18 14:28:31 +02:00
Min RK
aee3c74681 Merge origin/master into named_servers 2017-07-17 10:53:17 +02:00
Min RK
653a39c05e checkpoint: named server state 2017-07-17 10:41:36 +02:00
Min RK
a4a5781f7f invoke app when testing single-user 2017-06-28 21:55:15 +01:00
Min RK
194d2b9639 handle oauth id checks in tests 2017-06-28 21:55:15 +01:00
Min RK
5e55753baa various cleanup to get most tests passing (yay!) 2017-05-04 12:16:47 +02:00
Min RK
c7ea106675 use User wrappers in test_spawner 2017-04-05 16:12:29 +02:00
Min RK
67d6de9f68 don't forget to yield 2017-02-15 11:30:34 +01:00
Min RK
7afbe952e6 test
take pytest-tornado for a spin

it's nice!
2017-02-13 17:55:50 +01:00
Min RK
b8f4803ef4 Deprecate %U username substitution
use Python format-strings instead.
2016-09-15 12:05:46 +02:00
Min RK
3159b61ae7 return (ip, port) from Spawner.start
removes the need for Spawners to set db state themselves in most cases

Should be backward-compatible with warnings.
2016-07-25 16:54:15 +02:00
Min RK
592a084a28 set API token in single-user-spawner test 2016-07-25 15:57:43 +02:00
Min RK
67ccfc7eb7 increase some test coverage 2016-03-07 16:13:57 +01:00
Min RK
f626d2f6e5 use 127.0.0.1 instead of localhost
localhost can cause some issues on badly behaved or misconfigured systems,
and 127 seems simpler.
2016-02-03 10:30:09 +01:00
Min RK
8146af7240 make jupyterhub-singleuser a script
instead of a module in the package

makes it easier to do `/path/to/python $(which jupyterhub-singleuser)`
2016-01-20 15:41:54 +01:00
Min RK
7477f2f6d1 make sure to launch single-user server at least once in tests 2015-06-24 08:47:51 -07:00
Min RK
f81d4ba44c update tests with new default server ip ('')
and verify that starting a Spawner sets ip to localhost
2015-03-02 16:48:21 -08:00
Min RK
e265452d16 give spawners a second to start in tests
avoids intermittent test failures when interpreter initialization catches the signal
instead of the inner loop
2015-02-28 13:19:53 -08:00
Min RK
8cd2a55aa8 give Spawners, Authenticators db access
as self.db
2015-01-16 16:38:30 -08:00
Min RK
c4913ffc96 remove sudo
add SudoSpawner in separate repo,
which works much better than this ever did.
2014-12-04 11:06:20 -08:00
Min RK
2d6f76d778 shorten interrupt timeout 2014-10-30 10:23:58 -07:00
MinRK
5c87461605 add mock utils to tests
basic testing framework to get starting writing and testing the REST API

including tests for the authorizations API,
the only API URL defined so far.
2014-09-13 16:11:22 -07:00
MinRK
67e12c1a5e use run_sync to run coroutines in sync contexts
allows using py.test stuff in spawner/auth tests
2014-09-12 15:58:48 -07:00
MinRK
534eee46fc rename db.py orm.py
less confusing to have self.db and orm.User
than self.db and db.User.
2014-08-25 15:10:28 -07:00
MinRK
1f5720bcc0 test basic spawning 2014-08-25 12:39:46 -07:00