|
| 1 | +from ocflib.vhost.application import get_app_vhosts |
| 2 | +from ocflib.vhost.mail import get_mail_vhosts |
| 3 | +from ocflib.vhost.mail import vhosts_for_user |
| 4 | +from ocflib.vhost.web import get_vhosts |
| 5 | +from ocflib.vhost.web import has_vhost |
| 6 | + |
| 7 | + |
| 8 | +def test_app_vhosts(): |
| 9 | + app_vhosts = get_app_vhosts() |
| 10 | + |
| 11 | + # Make sure we're actually getting some app vhosts back |
| 12 | + assert(any(app_vhosts)) |
| 13 | + |
| 14 | + # Check that dev-app.o.b.e exists as an app vhost (this is used for testing |
| 15 | + # by OCF staff, so it's likely to stick around). It should also be owned by |
| 16 | + # the ggroup user. |
| 17 | + assert('dev-app.ocf.berkeley.edu' in app_vhosts) |
| 18 | + assert(app_vhosts['dev-app.ocf.berkeley.edu']['username'] == 'ggroup') |
| 19 | + |
| 20 | + # Ensure that there's no nossl flags present, we only support SSL vhosts |
| 21 | + # as of rt#5347 |
| 22 | + nossl_flags = [ |
| 23 | + vhost['flags'] |
| 24 | + for vhost in app_vhosts.values() if 'nossl' in vhost['flags'] |
| 25 | + ] |
| 26 | + assert(not any(nossl_flags)) |
| 27 | + |
| 28 | + |
| 29 | +def test_mail_vhosts(): |
| 30 | + mail_vhosts = get_mail_vhosts() |
| 31 | + |
| 32 | + # Make sure we're actually getting some app vhosts back |
| 33 | + assert(any(mail_vhosts)) |
| 34 | + |
| 35 | + # Check that the ggroup user has some mail vhosts (these are used for |
| 36 | + # testing by OCF staff so they're likely to stick around) |
| 37 | + assert(any(vhosts_for_user('ggroup'))) |
| 38 | + |
| 39 | + # Check that dev-vhost.o.b.e exists as an mail vhost (this is used for |
| 40 | + # testing by OCF staff, so it's likely to stick around) |
| 41 | + assert( |
| 42 | + 'dev-vhost.ocf.berkeley.edu' in {vhost.domain for vhost in mail_vhosts} |
| 43 | + ) |
| 44 | + |
| 45 | + |
| 46 | +def test_web_vhosts(): |
| 47 | + web_vhosts = get_vhosts() |
| 48 | + |
| 49 | + # Make sure we're actually getting some vhosts back |
| 50 | + assert(any(web_vhosts)) |
| 51 | + |
| 52 | + # Ensure the 'staff' and 'ggroup' users have some vhosts. These are likely |
| 53 | + # to always stick around as they are owned by the OCF and there are |
| 54 | + # multiple of them present for each user |
| 55 | + assert(has_vhost('staff')) |
| 56 | + assert(has_vhost('ggroup')) |
| 57 | + |
| 58 | + # Check that dev-vhost.o.b.e exists as a web vhost (this is used for |
| 59 | + # testing by OCF staff, so it's likely to stick around). It should also |
| 60 | + # have a dev-host-alias.o.b.e alias present |
| 61 | + assert('dev-vhost.ocf.berkeley.edu' in web_vhosts) |
| 62 | + aliases = web_vhosts['dev-vhost.ocf.berkeley.edu']['aliases'] |
| 63 | + assert('dev-vhost-alias.ocf.berkeley.edu' in aliases) |
| 64 | + |
| 65 | + flags = [vhost['flags'] for vhost in web_vhosts.values() if vhost['flags']] |
| 66 | + # Ensure that there's no nossl flags present, we only support SSL vhosts |
| 67 | + # as of rt#5347. |
| 68 | + assert(not any([flag_list for flag_list in flags if 'nossl' in flag_list])) |
| 69 | + # hsts flags are still allowed (but may become the default sometime and be |
| 70 | + # removed) |
| 71 | + assert(any([flag_list for flag_list in flags if 'hsts' in flag_list])) |
0 commit comments