|
1 | 1 | import shutil, errno, pytest, json, gzip, os, re |
2 | 2 |
|
3 | 3 | from roundup import i18n |
| 4 | +from roundup import password |
4 | 5 | from roundup.anypy.strings import b2s |
5 | 6 | from roundup.cgi.wsgi_handler import RequestDispatcher |
6 | 7 | from .wsgi_liveserver import LiveServerTestCase |
@@ -62,6 +63,10 @@ def setup_class(cls): |
62 | 63 | # open the database |
63 | 64 | cls.db = cls.instance.open('admin') |
64 | 65 |
|
| 66 | + # add a user without edit access for status. |
| 67 | + cls.db.user.create(username="fred", roles='User', |
| 68 | + password=password. Password( 'sekrit'), address='[email protected]') |
| 69 | + |
65 | 70 | # set the url the test instance will run at. |
66 | 71 | cls.db.config['TRACKER_WEB'] = "http://localhost:9001/" |
67 | 72 | # set up mailhost so errors get reported to debuging capture file |
@@ -914,6 +919,34 @@ def test_login_fail_then_succeed(self): |
914 | 919 | # look for change in text in sidebar post login |
915 | 920 | self.assertIn('<b>Hello, admin</b>', f.text) |
916 | 921 |
|
| 922 | + def test__generic_item_template(self): |
| 923 | + """Load /status1 object. Admin has edit rights so should see |
| 924 | + a submit button. fred doesn't have edit rights |
| 925 | + so should not have a submit button. |
| 926 | + """ |
| 927 | + for user in ["admin", "fred"]: |
| 928 | + # Set up session to manage cookies <insert blue monster here> |
| 929 | + session = requests.Session() |
| 930 | + session.headers.update({'Origin': self.url_base()}) |
| 931 | + |
| 932 | + # login using form |
| 933 | + login = {"__login_name": user, '__login_password': 'sekrit', |
| 934 | + "@action": "login"} |
| 935 | + f = session.post(self.url_base()+'/', data=login) |
| 936 | + # look for change in text in sidebar post login |
| 937 | + self.assertIn('Hello, %s'%user, f.text) |
| 938 | + f = session.post(self.url_base()+'/status7', data=login) |
| 939 | + print(f.content) |
| 940 | + |
| 941 | + # status1's name is unread |
| 942 | + self.assertIn(b'done-cbb', f.content) |
| 943 | + |
| 944 | + if user == 'admin': |
| 945 | + self.assertIn(b'<input name="submit_button" type="submit" value="Submit Changes">', f.content) |
| 946 | + else: |
| 947 | + self.assertNotIn(b'<input name="submit_button" type="submit" value="Submit Changes">', f.content) |
| 948 | + |
| 949 | + |
917 | 950 | def test_new_issue_with_file_upload(self): |
918 | 951 | # Set up session to manage cookies <insert blue monster here> |
919 | 952 | session = requests.Session() |
|
0 commit comments