root / helpdesk / tests.py @ c130b56e
History | View | Annotate | Download (2.1 kB)
1 | 0e3918f3 | Georgios Gousios | # vim: set fileencoding=utf-8 :
|
---|---|---|---|
2 | 0e3918f3 | Georgios Gousios | # Copyright 2011 GRNET S.A. All rights reserved.
|
3 | 0e3918f3 | Georgios Gousios | #
|
4 | 0e3918f3 | Georgios Gousios | # Redistribution and use in source and binary forms, with or without
|
5 | 0e3918f3 | Georgios Gousios | # modification, are permitted provided that the following conditions
|
6 | 0e3918f3 | Georgios Gousios | # are met:
|
7 | 0e3918f3 | Georgios Gousios | #
|
8 | 0e3918f3 | Georgios Gousios | # 1. Redistributions of source code must retain the above copyright
|
9 | 0e3918f3 | Georgios Gousios | # notice, this list of conditions and the following disclaimer.
|
10 | 0e3918f3 | Georgios Gousios | #
|
11 | 0e3918f3 | Georgios Gousios | # 2. Redistributions in binary form must reproduce the above copyright
|
12 | 0e3918f3 | Georgios Gousios | # notice, this list of conditions and the following disclaimer in the
|
13 | 0e3918f3 | Georgios Gousios | # documentation and/or other materials provided with the distribution.
|
14 | 0e3918f3 | Georgios Gousios | #
|
15 | 0e3918f3 | Georgios Gousios | # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
16 | 0e3918f3 | Georgios Gousios | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17 | 0e3918f3 | Georgios Gousios | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18 | 0e3918f3 | Georgios Gousios | # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
19 | 0e3918f3 | Georgios Gousios | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20 | 0e3918f3 | Georgios Gousios | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
21 | 0e3918f3 | Georgios Gousios | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
22 | 0e3918f3 | Georgios Gousios | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
23 | 0e3918f3 | Georgios Gousios | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
24 | 0e3918f3 | Georgios Gousios | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25 | 0e3918f3 | Georgios Gousios | # SUCH DAMAGE.
|
26 | 0e3918f3 | Georgios Gousios | #
|
27 | 0e3918f3 | Georgios Gousios | # The views and conclusions contained in the software and documentation are
|
28 | 0e3918f3 | Georgios Gousios | # those of the authors and should not be interpreted as representing official
|
29 | 0e3918f3 | Georgios Gousios | # policies, either expressed or implied, of GRNET S.A.
|
30 | 0e3918f3 | Georgios Gousios | |
31 | 0e3918f3 | Georgios Gousios | from django.test import TestCase |
32 | 0e3918f3 | Georgios Gousios | from django.test.client import Client |
33 | 0e3918f3 | Georgios Gousios | |
34 | 0e3918f3 | Georgios Gousios | from synnefo.helpdesk.middleware import check_ip |
35 | 0e3918f3 | Georgios Gousios | |
36 | 0e3918f3 | Georgios Gousios | class HelpdeskTestCase(TestCase): |
37 | 0e3918f3 | Georgios Gousios | apibase = '/api/v1.1'
|
38 | 0e3918f3 | Georgios Gousios | |
39 | 0e3918f3 | Georgios Gousios | def setUp(self): |
40 | 0e3918f3 | Georgios Gousios | self.client = Client()
|
41 | 0e3918f3 | Georgios Gousios | |
42 | 0e3918f3 | Georgios Gousios | def test_check_ip(self): |
43 | 0e3918f3 | Georgios Gousios | range = ('127.0.0.1', '195.251.249.0') |
44 | 0e3918f3 | Georgios Gousios | |
45 | 0e3918f3 | Georgios Gousios | ip = '127.0.0.1'
|
46 | 0e3918f3 | Georgios Gousios | self.assertTrue(check_ip(ip, range)) |
47 | 0e3918f3 | Georgios Gousios | |
48 | 0e3918f3 | Georgios Gousios | ip = '195.251.249.212'
|
49 | 0e3918f3 | Georgios Gousios | self.assertTrue(check_ip(ip, range)) |
50 | 0e3918f3 | Georgios Gousios | |
51 | 0e3918f3 | Georgios Gousios | ip = '195.234.249.2'
|
52 | 0e3918f3 | Georgios Gousios | self.assertFalse(check_ip(ip, range)) |