]> git.ipfire.org Git - thirdparty/patchwork.git/log
thirdparty/patchwork.git
6 years agoREST: A check must specify a state
Daniel Axtens [Mon, 29 Apr 2019 16:57:01 +0000 (02:57 +1000)] 
REST: A check must specify a state

The Ozlabs crew noticed that a check without a state caused a
KeyError in data['state']. Mark state as mandatory, check for
it, and add a test.

Reported-by: Russell Currey <ruscur@russell.cc>
Reported-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoREST: Handle regular form data requests for checks
Daniel Axtens [Mon, 29 Apr 2019 15:33:16 +0000 (01:33 +1000)] 
REST: Handle regular form data requests for checks

08d1459a4a40 ("Add REST API validation using OpenAPI schema") moved
all API requests to JSON blobs rather than form data.

dc48fbce99ef ("REST: Handle JSON requests") attempted to change the
check serialiser to handle this. However, because both a JSON dict
and a QueryDict satisfy isinstance(data, dict), everything was handled
as JSON and the old style requests were broken.

Found in the process of debugging issues from the OzLabs PW & Snowpatch
crew - I'm not sure if they actually hit this one, but kudos to them
anyway as we wouldn't have found it without them.

Fixes: dc48fbce99ef ("REST: Handle JSON requests")
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agonotifications: fix notification expiry when no user is associated
Jeremy Kerr [Sat, 27 Apr 2019 11:12:16 +0000 (19:12 +0800)] 
notifications: fix notification expiry when no user is associated

It's possible that an EmailConfirmation object will have no associated
user (eg, for email opt-out, which does not require a user object). In
this case, we will see a NULL value for EmailConfirmation.user_id.

However, having a NULL value appear in a SQL 'IN' clause will match
every value. This means that once one of these null-user
EmailConfirmations is present, we will never expire any non-active user
accounts.

This change adds a filter for a valid user_id when we query for active
EmailConfirmation objects. This means we'll have a valid values set to
use in the pending_confs set.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
[dja: fix pep8 issue]
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoUpdate psycopg2-binary from 2.8.1 to 2.8.2
pyup-bot [Mon, 15 Apr 2019 18:13:32 +0000 (19:13 +0100)] 
Update psycopg2-binary from 2.8.1 to 2.8.2

6 years agoUpdate psycopg2-binary from 2.8.1 to 2.8.2
pyup-bot [Mon, 15 Apr 2019 18:13:31 +0000 (19:13 +0100)] 
Update psycopg2-binary from 2.8.1 to 2.8.2

6 years agoUpdate psycopg2-binary from 2.7.7 to 2.8.1
pyup-bot [Sat, 6 Apr 2019 20:58:39 +0000 (21:58 +0100)] 
Update psycopg2-binary from 2.7.7 to 2.8.1

6 years agoUpdate psycopg2-binary from 2.7.7 to 2.8.1
pyup-bot [Sat, 6 Apr 2019 20:58:38 +0000 (21:58 +0100)] 
Update psycopg2-binary from 2.7.7 to 2.8.1

6 years agoUpdate jinja2 from 2.10 to 2.10.1
pyup-bot [Sat, 6 Apr 2019 20:58:35 +0000 (21:58 +0100)] 
Update jinja2 from 2.10 to 2.10.1

6 years agoFix YAML loader warning
Daniel Axtens [Fri, 15 Mar 2019 06:27:40 +0000 (17:27 +1100)] 
Fix YAML loader warning

In my tests I'm seeing:
/home/patchwork/patchwork/patchwork/tests/api/validator.py:229:
YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated,
as the default Loader is unsafe. Please read https://msg.pyyaml.org/load
for full details.

Fix this by using the safe loader in the tests.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate sphinx_rtd_theme from 0.4.2 to 0.4.3
pyup-bot [Tue, 12 Feb 2019 21:45:36 +0000 (21:45 +0000)] 
Update sphinx_rtd_theme from 0.4.2 to 0.4.3

6 years agoUpdate sqlparse from 0.2.4 to 0.3.0
pyup-bot [Mon, 11 Mar 2019 19:42:59 +0000 (20:42 +0100)] 
Update sqlparse from 0.2.4 to 0.3.0

6 years agoUpdate sqlparse from 0.2.4 to 0.3.0
pyup-bot [Mon, 11 Mar 2019 19:42:58 +0000 (20:42 +0100)] 
Update sqlparse from 0.2.4 to 0.3.0

6 years agoUpdate django from 1.11.18 to 1.11.20
Stephen Finucane [Thu, 7 Mar 2019 11:55:04 +0000 (11:55 +0000)] 
Update django from 1.11.18 to 1.11.20

6 years agoui: Space in filter radio buttons
Thomas Monjalon [Tue, 8 Jan 2019 12:38:46 +0000 (12:38 +0000)] 
ui: Space in filter radio buttons

There was no space between radio button and associated text
in the filters form.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoui: Shrink vertical space of patch list
Thomas Monjalon [Tue, 8 Jan 2019 12:38:45 +0000 (12:38 +0000)] 
ui: Shrink vertical space of patch list

The margin above the filter box is removed because there is
already a margin below the navigation bar.

The vertical padding between rows is reduced
while the horizontal padding between columns is increased.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate djangorestframework from 3.9.1 to 3.9.2
pyup-bot [Sun, 3 Mar 2019 21:13:38 +0000 (21:13 +0000)] 
Update djangorestframework from 3.9.1 to 3.9.2

6 years agoUpdate djangorestframework from 3.9.1 to 3.9.2
pyup-bot [Sun, 3 Mar 2019 21:13:37 +0000 (21:13 +0000)] 
Update djangorestframework from 3.9.1 to 3.9.2

6 years agoparser: recognise git commit consisting only of empty new file
Daniel Axtens [Thu, 28 Feb 2019 04:29:53 +0000 (15:29 +1100)] 
parser: recognise git commit consisting only of empty new file

Commits with only an empty new file are liable to be missed.
The parser state machine doesn't recognise the headers "new
file mode" and "index": teach it about them.

Add a test to demonstrate.

It's a little bit academic as you don't usually send patches like
that but sometimes you do, especially if you're a snowpatch dev :)

Closes: #256
Reported-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate openapi-core from 0.7.1 to 0.8.0
pyup-bot [Thu, 28 Feb 2019 14:37:30 +0000 (14:37 +0000)] 
Update openapi-core from 0.7.1 to 0.8.0

6 years agoBeautify check counts in the patch list view
Ali Alnubani [Tue, 8 Jan 2019 12:38:47 +0000 (12:38 +0000)] 
Beautify check counts in the patch list view

This patch [1] adds colors to the checks in the patch list view.
The colors are set based on the check's priority, with FAILURE
having the highest priority, followed by WARNING, and then SUCCESS.
Only the check with the highest priority and non-zero count
will be colored. This is to make failures and warnings more visible.

The patch also [2] replaces zero counts with a '-' for
FAILUREs and WARNINGs.
The SUCCESS count will only be replaced by a '-'
when all other checks have zero counts too.

Suggested-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoFix return code when getting patch information fails
Ali Alnubani [Tue, 8 Jan 2019 12:38:45 +0000 (12:38 +0000)] 
Fix return code when getting patch information fails

The `info` command always exits with success, even if
the patch didn't exist.
Modified to exit with a non-zero exit status and
print an error message in that case.

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Fix user's profile url
Ali Alnubani [Mon, 25 Feb 2019 08:09:29 +0000 (08:09 +0000)] 
docs: Fix user's profile url

Signed-off-by: Ali Alnubani <alialnu@mellanox.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate django from 2.1.5 to 2.1.7
pyup-bot [Mon, 11 Feb 2019 19:03:13 +0000 (19:03 +0000)] 
Update django from 2.1.5 to 2.1.7

6 years agoUpdate django from 2.1.5 to 2.1.7
pyup-bot [Mon, 11 Feb 2019 19:03:11 +0000 (19:03 +0000)] 
Update django from 2.1.5 to 2.1.7

6 years agoUpdate python-dateutil from 2.7.5 to 2.8.0
pyup-bot [Tue, 5 Feb 2019 17:06:00 +0000 (18:06 +0100)] 
Update python-dateutil from 2.7.5 to 2.8.0

6 years agodocs: Integrate API schema into docs
Stephen Finucane [Sat, 27 Oct 2018 00:31:43 +0000 (01:31 +0100)] 
docs: Integrate API schema into docs

This takes advantage of the sphinxcontrib-openapi Sphinx extension,
which allows us to embed the REST API documentation into our docs quite
nicely.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Move REST API guide to subfolder
Stephen Finucane [Sat, 27 Oct 2018 00:39:38 +0000 (01:39 +0100)] 
docs: Move REST API guide to subfolder

We're going to dramatically expand these docs, so let's set up room to
do so.

This shouldn't break any links as we're using 'htmldir' output on
ReadTheDocs.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotox: Use 'dirhtml' builder for docs
Stephen Finucane [Mon, 28 Jan 2019 21:09:40 +0000 (21:09 +0000)] 
tox: Use 'dirhtml' builder for docs

This is what we use for 'patchwork.readthedocs.io'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Remove crud from conf.py
Stephen Finucane [Sat, 27 Oct 2018 00:36:40 +0000 (01:36 +0100)] 
docs: Remove crud from conf.py

Most of this was removed in a previous release but there is yet more to
go. These values are all (a) defaults or (b) never triggered. Remove
them.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate psycopg2-binary from 2.7.6.1 to 2.7.7
pyup-bot [Tue, 22 Jan 2019 18:48:02 +0000 (19:48 +0100)] 
Update psycopg2-binary from 2.7.6.1 to 2.7.7

6 years agoUpdate psycopg2-binary from 2.7.6.1 to 2.7.7
pyup-bot [Tue, 22 Jan 2019 18:48:01 +0000 (19:48 +0100)] 
Update psycopg2-binary from 2.7.6.1 to 2.7.7

6 years agoUpdate django (Py2) from 1.11.15 to 1.11.18
Stephen Finucane [Mon, 28 Jan 2019 20:55:16 +0000 (20:55 +0000)] 
Update django (Py2) from 1.11.15 to 1.11.18

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate django-filter from 2.0.0 to 2.1.0
pyup-bot [Sun, 20 Jan 2019 20:56:58 +0000 (21:56 +0100)] 
Update django-filter from 2.0.0 to 2.1.0

6 years agoUpdate django-filter from 2.0.0 to 2.1.0
pyup-bot [Sun, 20 Jan 2019 20:56:56 +0000 (21:56 +0100)] 
Update django-filter from 2.0.0 to 2.1.0

6 years agoUpdate djangorestframework from 3.9.0 to 3.9.1
pyup-bot [Wed, 16 Jan 2019 15:30:55 +0000 (15:30 +0000)] 
Update djangorestframework from 3.9.0 to 3.9.1

6 years agoUpdate djangorestframework from 3.9.0 to 3.9.1
pyup-bot [Wed, 16 Jan 2019 15:30:54 +0000 (15:30 +0000)] 
Update djangorestframework from 3.9.0 to 3.9.1

6 years agoUpdate django from 2.1.4 to 2.1.5
pyup-bot [Fri, 4 Jan 2019 17:43:35 +0000 (18:43 +0100)] 
Update django from 2.1.4 to 2.1.5

6 years agoUpdate django from 2.1.4 to 2.1.5
pyup-bot [Fri, 4 Jan 2019 17:43:34 +0000 (18:43 +0100)] 
Update django from 2.1.4 to 2.1.5

6 years agoadmin: Further optimize queries
Stephen Finucane [Fri, 2 Nov 2018 17:45:20 +0000 (17:45 +0000)] 
admin: Further optimize queries

To count the amount of received patches for a series, we only need the
patch's series field.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoadmin: Show series.submitter in admin view
Stephen Finucane [Fri, 2 Nov 2018 17:34:10 +0000 (17:34 +0000)] 
admin: Show series.submitter in admin view

Display this by default and allow filtering by it. While we're here,
also allow patches to be filtered by submitter.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Configure User.first_name, User.last_name
Stephen Finucane [Mon, 29 May 2017 14:42:45 +0000 (15:42 +0100)] 
tests: Configure User.first_name, User.last_name

'User.name' is not a valid attribute. This also highlights a small issue
with the existing tests.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Detail JSON PATCH requests
Stephen Finucane [Thu, 1 Jun 2017 13:48:22 +0000 (14:48 +0100)] 
docs: Detail JSON PATCH requests

It turns out it is possible to make PATCH requests with JSON bodies
rather than form-encoded data - you just need to include a Content-Type
header. Document this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Reformat schemas
Stephen Finucane [Mon, 24 Dec 2018 13:40:02 +0000 (13:40 +0000)] 
docs: Reformat schemas

Tested using 'yamllint'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Add parameter descriptions, types
Stephen Finucane [Sun, 23 Dec 2018 15:38:51 +0000 (15:38 +0000)] 
docs: Add parameter descriptions, types

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Move 'parameter.schema.description' to 'parameter'
Stephen Finucane [Sun, 23 Dec 2018 14:58:25 +0000 (14:58 +0000)] 
docs: Move 'parameter.schema.description' to 'parameter'

As noted in a bug against the spec [1], there is some duplication here.
Go with the more obvious path until that confusion is cleared up.

[1] https://github.com/OAI/OpenAPI-Specification/issues/1788

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate mysqlclient from 1.3.13 to 1.3.14
pyup-bot [Sat, 22 Dec 2018 23:09:58 +0000 (23:09 +0000)] 
Update mysqlclient from 1.3.13 to 1.3.14

6 years agoPin jinja2 to latest version 2.10
pyup-bot [Sat, 22 Dec 2018 17:44:36 +0000 (17:44 +0000)] 
Pin jinja2 to latest version 2.10

6 years agoUpdate psycopg2-binary from 2.7.6 to 2.7.6.1
pyup-bot [Sun, 11 Nov 2018 15:42:40 +0000 (16:42 +0100)] 
Update psycopg2-binary from 2.7.6 to 2.7.6.1

6 years agoUpdate psycopg2-binary from 2.7.6 to 2.7.6.1
pyup-bot [Sun, 11 Nov 2018 15:42:38 +0000 (16:42 +0100)] 
Update psycopg2-binary from 2.7.6 to 2.7.6.1

6 years agoUpdate django-debug-toolbar from 1.10.1 to 1.11
pyup-bot [Mon, 3 Dec 2018 18:11:33 +0000 (23:56 +0545)] 
Update django-debug-toolbar from 1.10.1 to 1.11

6 years agoUpdate django from 2.1.3 to 2.1.4
pyup-bot [Mon, 3 Dec 2018 18:11:28 +0000 (23:56 +0545)] 
Update django from 2.1.3 to 2.1.4

6 years agoUpdate django from 2.1.3 to 2.1.4
pyup-bot [Mon, 3 Dec 2018 18:11:27 +0000 (23:56 +0545)] 
Update django from 2.1.3 to 2.1.4

6 years agoparser: Ensure whitespace is stripped for long headers
Stephen Finucane [Sun, 4 Nov 2018 14:06:03 +0000 (14:06 +0000)] 
parser: Ensure whitespace is stripped for long headers

RFC2822 states that long headers can be wrapped using CRLF followed by
WSP [1]. For example:

    Subject: Foo bar,
     baz

Should be parsed as:

    Foo bar,baz

While we were stripping the former, we were not stripping the
latter. This mean that we ended up with the following:

    Foo bar, baz

Resolve this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #197
6 years agomodels: Ensure UserProfile.user is configured
Stephen Finucane [Sat, 3 Nov 2018 21:47:51 +0000 (21:47 +0000)] 
models: Ensure UserProfile.user is configured

Django Admin seems to be doing something funky with how it's handling
the creation of a User's corresponding UserProfile instance when
modelled as an inline field. Re-setting the UserProfile.user attribute
seems to resolve the issue, so do just that.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #110
6 years agoAdd REST API validation using OpenAPI schema
Stephen Finucane [Thu, 15 Nov 2018 12:57:58 +0000 (13:57 +0100)] 
Add REST API validation using OpenAPI schema

Add validation using the rather excellent 'openapi_core' library. The
biggest issue we have to contend with is the fact that 'openapi_core'
expects us to be able to provide a templated URL string for each request
(e.g. '/api/patches/123/' would become '/api/patches/<id>/') and Django
doesn't provide a way to do this [*]. We work around this by
reverse-engineering some of the Django code to turn a URL to its
matching regex, which we can then easily convert into a template string.
It's kind of hacky and not at all portable but, crucially, it does work
and has highlighted some nice bugs in the API that have already merged.

Going forward, we can probably modify 'openapi_core' somewhat to remove
the need for the templated URL string. If and when this happens, most of
the funkier code here can happily go away.

[*] Django 2.0+ [1] does actually provide a way to do template
string-based URLs and in fact recommends them now, with regexes being
reserved for more advanced corner cases. However, we don't want to drop
support for the Django 1.11 yet as it is the most recent LTS release.

[1] https://docs.djangoproject.com/en/2.1/ref/urls/#django.urls.path

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Remove old Swagger 2.0 spec
Stephen Finucane [Fri, 7 Dec 2018 12:25:49 +0000 (12:25 +0000)] 
docs: Remove old Swagger 2.0 spec

This was incomplete and wrong in many places. It's since been replaced
by the OpenAPI 3.0.0 specs, so we have happily remove this now.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Store versioned OpenAPI schemas
Stephen Finucane [Mon, 10 Dec 2018 10:46:15 +0000 (10:46 +0000)] 
docs: Store versioned OpenAPI schemas

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Make API document versioned
Stephen Finucane [Fri, 26 Oct 2018 23:49:17 +0000 (00:49 +0100)] 
docs: Make API document versioned

OpenAPI doesn't appear to support versioning natively, suggesting
instead that separate documents are kept. Rather than doing this
manually, let's use a templating tool - Jinja2, in this case - to
generate these document for us from a single master document.

Note that while we can now auto-generate these whenever we need them
(and we tend to avoid storing auto-generated assets in VCS), these
change so rarely that it's easier to just store them. This also means we
can reference the schemas themselves online. We do this in a following
change.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/events' resource
Stephen Finucane [Fri, 26 Oct 2018 21:12:57 +0000 (22:12 +0100)] 
docs: Document the '/events' resource

This is the final resource to document and also the most complicated, on
account of the polymorphism of the responses. However, with this done,
our first pass at an OpenAPI 3.0 schema is completed.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/patches/{patch_id}/checks' resource
Stephen Finucane [Fri, 26 Oct 2018 21:10:51 +0000 (22:10 +0100)] 
docs: Document the '/patches/{patch_id}/checks' resource

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/patch/{id}/comments' resource
Stephen Finucane [Fri, 26 Oct 2018 21:17:12 +0000 (22:17 +0100)] 
docs: Document the '/patch/{id}/comments' resource

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/covers/{id}/comments' resource
Stephen Finucane [Fri, 26 Oct 2018 21:16:04 +0000 (22:16 +0100)] 
docs: Document the '/covers/{id}/comments' resource

Our first nested resource. Nothing too weird here though, save for the
raising of a HTTP 404 on a list resource (due to a missing patch).

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/series' resource
Stephen Finucane [Fri, 26 Oct 2018 21:06:25 +0000 (22:06 +0100)] 
docs: Document the '/series' resource

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/patches' resource
Stephen Finucane [Fri, 26 Oct 2018 21:04:44 +0000 (22:04 +0100)] 
docs: Document the '/patches' resource

The big one (TM). Nothing too odd here though.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/covers' resource
Stephen Finucane [Fri, 26 Oct 2018 21:01:44 +0000 (22:01 +0100)] 
docs: Document the '/covers' resource

Again, we're adding embedded serializers before the main resource but
that will come.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/bundles' resource
Stephen Finucane [Fri, 26 Oct 2018 20:57:40 +0000 (21:57 +0100)] 
docs: Document the '/bundles' resource

This one's a little unusual too, in that we provide the embedded
serializer for resources we haven't defined the end resource for. That's
necessary in general, due to recursive references in the API
(series-patch, patch-series etc.) so might as well embrace it early.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/projects' resource
Stephen Finucane [Fri, 26 Oct 2018 20:52:49 +0000 (21:52 +0100)] 
docs: Document the '/projects' resource

This one's pretty straightforward.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/people' resource
Stephen Finucane [Fri, 26 Oct 2018 20:48:54 +0000 (21:48 +0100)] 
docs: Document the '/people' resource

This introduces our first use of embedded serializers, which are
separate models from the main ones. Other than that, this is pretty
standard.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Document the '/users' resource
Stephen Finucane [Fri, 26 Oct 2018 20:46:16 +0000 (21:46 +0100)] 
docs: Document the '/users' resource

This introduces our first use of parameters, both in the path and the
query. The latter are extracted out as they'll be used by later changes.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Start documenting API using OpenAPI
Stephen Finucane [Fri, 26 Oct 2018 20:42:02 +0000 (21:42 +0100)] 
docs: Start documenting API using OpenAPI

When the REST API was first added, we attempted to document it using
OpenAPI 2.0 (formerly Swagger). This was mostly never completed because
(a) it was really tedious and (b) no one was that bothered. However, as
we expand the range of clients for the REST API, having a well
documented API becomes more and more of an asset.

Start doing this by adding a brand new schema, this time using OpenAPI.
This will entirely replace the older schema and, as such, is namespaced
separately. We start by documenting '/' (i.e. the index) page and will
add additional resources as we go.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoREST: Handle JSON requests
Stephen Finucane [Fri, 7 Dec 2018 12:13:32 +0000 (12:13 +0000)] 
REST: Handle JSON requests

This was raising an attribute error when switching tests to use JSON
bodies instead of form-data.

  AttributeError: 'dict' object has no attribute '_mutable'

The easy fix is to check if it's a dictionary and avoid the mutability
check if so.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Use project.id in requests, not object
Stephen Finucane [Fri, 7 Dec 2018 11:45:46 +0000 (11:45 +0000)] 
tests: Use project.id in requests, not object

The object is not serializable.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Use valid URLs
Stephen Finucane [Thu, 6 Dec 2018 14:41:10 +0000 (14:41 +0000)] 
tests: Use valid URLs

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Start setting Project.listemail
Stephen Finucane [Mon, 3 Dec 2018 14:28:14 +0000 (14:28 +0000)] 
tests: Start setting Project.listemail

I'm not actually sure why this wasn't raising an error. Perhaps it's
because null validation for char fields happens in forms rather than at
the database level. In any case, this won't happen normally since we
only allow creation via the admin API so simply start setting this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoREST: Drop embedded bundle serializer
Stephen Finucane [Fri, 16 Nov 2018 22:59:20 +0000 (23:59 +0100)] 
REST: Drop embedded bundle serializer

This wasn't used anywhere and can therefore be removed.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoREST: Fix typo in embedded serializers
Stephen Finucane [Fri, 16 Nov 2018 20:17:53 +0000 (21:17 +0100)] 
REST: Fix typo in embedded serializers

This was preventing the v1.1 fields from getting dropped as intended.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #237
6 years agoREST: Handle unset series
Stephen Finucane [Fri, 16 Nov 2018 15:47:43 +0000 (16:47 +0100)] 
REST: Handle unset series

This was introduced in the recent "convert series from N:M to 1:N"
series. We take the opportunity to make the 'create_patch' and
'create_cover' utility methods a little smarter, in that series will
automatically be created for the patch/cover letter unless told not to.
This requires some related changes to other modules.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agosignals: Fix 'series-completed' event
Stephen Finucane [Mon, 29 Oct 2018 15:15:18 +0000 (15:15 +0000)] 
signals: Fix 'series-completed' event

I'm not sure how I ever intended this to work and there were no tests
verifying things. Fix it now and add tests to prevent it regressing.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 76505e91 ("models: Convert Series-Patch relationship to 1:N")
6 years agotests: Add 'store_samples' decorator to 'test_event'
Stephen Finucane [Mon, 29 Oct 2018 00:54:57 +0000 (00:54 +0000)] 
tests: Add 'store_samples' decorator to 'test_event'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add tests for '/events' resource
Stephen Finucane [Mon, 29 Oct 2018 00:53:40 +0000 (00:53 +0000)] 
tests: Add tests for '/events' resource

This highlights an issue that will be resolved in a future change.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_check'
Stephen Finucane [Sun, 28 Oct 2018 17:40:27 +0000 (17:40 +0000)] 
tests: Add 'store_samples' decorator to 'test_check'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_comment'
Stephen Finucane [Sun, 28 Oct 2018 17:31:19 +0000 (17:31 +0000)] 
tests: Add 'store_samples' decorator to 'test_comment'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_series'
Stephen Finucane [Sun, 28 Oct 2018 17:22:20 +0000 (17:22 +0000)] 
tests: Add 'store_samples' decorator to 'test_series'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_cover'
Stephen Finucane [Sun, 28 Oct 2018 17:14:55 +0000 (17:14 +0000)] 
tests: Add 'store_samples' decorator to 'test_cover'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_patch'
Stephen Finucane [Sun, 28 Oct 2018 17:14:45 +0000 (17:14 +0000)] 
tests: Add 'store_samples' decorator to 'test_patch'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_user'
Stephen Finucane [Sun, 28 Oct 2018 15:49:54 +0000 (15:49 +0000)] 
tests: Add 'store_samples' decorator to 'test_user'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_people'
Stephen Finucane [Sun, 28 Oct 2018 15:36:46 +0000 (15:36 +0000)] 
tests: Add 'store_samples' decorator to 'test_people'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_project'
Stephen Finucane [Sun, 28 Oct 2018 15:22:22 +0000 (15:22 +0000)] 
tests: Add 'store_samples' decorator to 'test_project'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_bundle'
Stephen Finucane [Sun, 28 Oct 2018 14:43:31 +0000 (14:43 +0000)] 
tests: Add 'store_samples' decorator to 'test_bundle'

Add the decorator to the 'test_bundle' test class. This involves
splitting up the test cases so that each test case we care about makes
only a single request. We also add a missing test to ensure private
bundles cannot be shown by anyone but the owner.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator
Stephen Finucane [Sun, 28 Oct 2018 14:40:31 +0000 (14:40 +0000)] 
tests: Add 'store_samples' decorator

We want to start including sample API requests and responses in our
documentation.  Given that these may get out of date over time, we
should really generate these things dynamically. Create a decorator that
will allow us to do just that.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoREST: Ensure submission exists for comment listing
Stephen Finucane [Sun, 28 Oct 2018 13:31:34 +0000 (13:31 +0000)] 
REST: Ensure submission exists for comment listing

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #225
6 years agoREST: Ensure patch exists for check creation
Stephen Finucane [Sun, 28 Oct 2018 13:31:12 +0000 (13:31 +0000)] 
REST: Ensure patch exists for check creation

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #226
6 years agoREST: Show 'web_url' in embedded series responses
Stephen Finucane [Fri, 26 Oct 2018 20:35:03 +0000 (21:35 +0100)] 
REST: Show 'web_url' in embedded series responses

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #224
Fixes: 9c179bf4c ("REST: Add 'web_url' link to API responses")
6 years agoREST: Add additional documentation
Stephen Finucane [Sat, 20 Oct 2018 22:20:52 +0000 (23:20 +0100)] 
REST: Add additional documentation

As noted in the Django REST Framework docs [1], views that support
multiple methods can and should split their documentation using
'method:' style delimiters. Do just this.

[1] https://www.django-rest-framework.org/topics/documenting-your-api/#documenting-your-views

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoDon't passthrough 'Content-Type: multipart/signed' header
Stephen Finucane [Sun, 4 Nov 2018 14:25:03 +0000 (14:25 +0000)] 
Don't passthrough 'Content-Type: multipart/signed' header

We don't GPG signatures, therefore this header is incorrect. Stop
passing it through.

Test for the other dropped header are also included.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Veronika Kabatova <vkabatov@redhat.com>
Closes: #221
7 years agoUpdate psycopg2-binary from 2.7.5 to 2.7.6
pyup-bot [Fri, 9 Nov 2018 11:57:36 +0000 (11:57 +0000)] 
Update psycopg2-binary from 2.7.5 to 2.7.6

7 years agoUpdate psycopg2-binary from 2.7.5 to 2.7.6
pyup-bot [Fri, 9 Nov 2018 11:57:34 +0000 (11:57 +0000)] 
Update psycopg2-binary from 2.7.5 to 2.7.6

7 years agoUpdate django from 2.1.2 to 2.1.3
pyup-bot [Fri, 2 Nov 2018 09:32:03 +0000 (09:32 +0000)] 
Update django from 2.1.2 to 2.1.3

7 years agoparser: Use 'objects.create' instead of 'save'
Stephen Finucane [Tue, 11 Sep 2018 22:39:54 +0000 (16:39 -0600)] 
parser: Use 'objects.create' instead of 'save'

As noted in the Django documentation [1], this lets us do things in one
step.

[1] https://docs.djangoproject.com/en/dev/topics/db/queries/#creating-objects

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Daniel Axtens <dja@axtens.net>
7 years agoREADME: Note latest version of requirements
Stephen Finucane [Tue, 30 Oct 2018 22:04:23 +0000 (22:04 +0000)] 
README: Note latest version of requirements

These were missed previously

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 8eb3719a ("Add support for django-filter 2.0")
Fixes: fab5571e ("Add support for Django REST Framework 3.9")