Merge lp:~robru/bileto/audit-logs into lp:bileto

Proposed by Robert Bruce Park
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 274
Merged at revision: 273
Proposed branch: lp:~robru/bileto/audit-logs
Merge into: lp:bileto
Diff against target: 107 lines (+39/-10)
5 files modified
Makefile (+1/-1)
db_migrations.sh (+12/-8)
tests/test_v1.py (+20/-0)
tickets/models.py (+4/-0)
tickets/v1.py (+2/-1)
To merge this branch: bzr merge lp:~robru/bileto/audit-logs
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Bruce Park (community) Approve
Review via email: mp+272972@code.launchpad.net

Commit message

Expand Comment model to accomodate Audit Logs.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:273
http://jenkins.qa.ubuntu.com/job/bileto-ci/66/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/bileto-ci/66/rebuild

review: Approve (continuous-integration)
Revision history for this message
Robert Bruce Park (robru) wrote :

Looks great in staging, db successfully migrated.

review: Approve
lp:~robru/bileto/audit-logs updated
274. By Robert Bruce Park

Allow bots with API_TOKEN to set arbitrary comment authors.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:274
http://jenkins.qa.ubuntu.com/job/bileto-ci/67/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/bileto-ci/67/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2015-09-24 15:44:44 +0000
3+++ Makefile 2015-09-30 20:05:58 +0000
4@@ -21,4 +21,4 @@
5
6 install-user:
7 [ -f "$$HOME/bileto.api.token" ] || uuid > "$$HOME/bileto.api.token"
8- # ./db_migrations.sh
9+ ./db_migrations.sh
10
11=== modified file 'db_migrations.sh'
12--- db_migrations.sh 2015-09-02 05:35:33 +0000
13+++ db_migrations.sh 2015-09-30 20:05:58 +0000
14@@ -4,12 +4,12 @@
15 # flask/sqlalchemy migrations bits aren't available for python3 in trusty.
16
17
18-CONNECTION=$(tr ':/@' ' ' < $HOME/bileto.postgresql.info)
19-USER=$(echo $CONNECTION | awk '{ print $2 }')
20-PASSWORD=$(echo $CONNECTION | awk '{ print $3 }')
21-HOST=$(echo $CONNECTION | awk '{ print $4 }')
22-PORT=$(echo $CONNECTION | awk '{ print $5 }')
23-DB=$(echo $CONNECTION | awk '{ print $6 }')
24+CONNECTION=$(tr ':/@' ' ' < "$HOME/bileto.postgresql.info")
25+USER=$(echo "$CONNECTION" | awk '{ print $2 }')
26+PASSWORD=$(echo "$CONNECTION" | awk '{ print $3 }')
27+HOST=$(echo "$CONNECTION" | awk '{ print $4 }')
28+PORT=$(echo "$CONNECTION" | awk '{ print $5 }')
29+DB=$(echo "$CONNECTION" | awk '{ print $6 }')
30
31
32 export PGPASSFILE=$(mktemp -t pgpass.XXX)
33@@ -25,10 +25,14 @@
34 $PG "SELECT pg_terminate_backend($pid);"
35 done
36
37-$PG "ALTER TABLE request ADD COLUMN job_log varchar(1000) DEFAULT '';" || true
38-$PG "ALTER TABLE request ADD COLUMN creator varchar(1000) DEFAULT '';" || true
39+$PG "ALTER TABLE comment ADD COLUMN log_url text DEFAULT '';" || true
40+$PG "ALTER TABLE comment ADD COLUMN published_versions text DEFAULT '';" || true
41+$PG "ALTER TABLE comment ADD COLUMN siloname varchar(1000) DEFAULT '';" || true
42
43 # These ones have succeeded in production and only kept for reference
44+# $PG "ALTER TABLE request ADD COLUMN job_log varchar(1000) DEFAULT '';" || true
45+# $PG "ALTER TABLE request ADD COLUMN creator varchar(1000) DEFAULT '';" || true
46+
47 # for column in status sources search; do
48 # $PG "ALTER TABLE request ALTER COLUMN $column SET DATA TYPE text;"
49 # done
50
51=== modified file 'tests/test_v1.py'
52--- tests/test_v1.py 2015-09-30 18:26:56 +0000
53+++ tests/test_v1.py 2015-09-30 20:05:58 +0000
54@@ -481,6 +481,26 @@
55 self.assertEqual(data['request_id'], 1)
56 self.assertEqual(data['text'], 'all systems go')
57
58+ @patch('tickets.v1.API_TOKEN', FAKE_TOKEN)
59+ def test_post_comment_by_bot(self):
60+ """Ensure jenkins can inject comments with API token."""
61+ self.test_create_ticket('alpha')
62+ with self.app.session_transaction() as sesh:
63+ sesh.update(teams='', nickname='')
64+ ret = self.app.post(
65+ '/v1/comment?token=faken',
66+ data=json.dumps(dict(
67+ request_id=1, author='job starter', text='all systems go')),
68+ content_type='application/json')
69+ self.assertEqual(ret.status_code, 201)
70+ self.assertEqual(Comment.query.get(1).text, 'all systems go')
71+ ret = self.app.get('/v1/tickets')
72+ data = parse(ret.data)['requests'][0]['comments'][0]
73+ self.assertEqual(data['author'], 'job starter')
74+ self.assertEqual(data['id'], 1)
75+ self.assertEqual(data['request_id'], 1)
76+ self.assertEqual(data['text'], 'all systems go')
77+
78 @patch('tickets.v1.LOGFILE', FAKE_LOG)
79 def test_errors(self):
80 """Ensure we can read the log file."""
81
82=== modified file 'tickets/models.py'
83--- tickets/models.py 2015-09-30 18:42:12 +0000
84+++ tickets/models.py 2015-09-30 20:05:58 +0000
85@@ -217,4 +217,8 @@
86 text = db.Column(db.Text, default='')
87 date = db.Column(db.DateTime, default=right_now)
88
89+ log_url = db.Column(db.Text, default='')
90+ published_versions = db.Column(db.Text, default='')
91+ siloname = db.Column(db.String(CHAR_MAX), default='')
92+
93 verboten = ('id', 'date')
94
95=== modified file 'tickets/v1.py'
96--- tickets/v1.py 2015-09-30 18:26:56 +0000
97+++ tickets/v1.py 2015-09-30 20:05:58 +0000
98@@ -222,7 +222,8 @@
99 """Create a new comment."""
100 authenticate()
101 assert_json()
102- request.json['author'] = session['nickname']
103+ if not check_api_token():
104+ request.json['author'] = session['nickname']
105 comment = Comment(**request.json)
106 db.session.add(comment)
107 db.session.commit()

Subscribers

People subscribed via source and target branches