aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* docs: Reformat schemasStephen Finucane2018-12-24
| | | | | | Tested using 'yamllint'. Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Add parameter descriptions, typesStephen Finucane2018-12-24
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Move 'parameter.schema.description' to 'parameter'Stephen Finucane2018-12-24
| | | | | | | | | 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>
* Update mysqlclient from 1.3.13 to 1.3.14pyup-bot2018-12-23
|
* Pin jinja2 to latest version 2.10pyup-bot2018-12-22
|
* Update psycopg2-binary from 2.7.6 to 2.7.6.1pyup-bot2018-12-22
|
* Update psycopg2-binary from 2.7.6 to 2.7.6.1pyup-bot2018-12-22
|
* Update django-debug-toolbar from 1.10.1 to 1.11pyup-bot2018-12-22
|
* Update django from 2.1.3 to 2.1.4pyup-bot2018-12-22
|
* Update django from 2.1.3 to 2.1.4pyup-bot2018-12-22
|
* parser: Ensure whitespace is stripped for long headersStephen Finucane2018-12-22
| | | | | | | | | | | | | | | | | | | | | | 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
* models: Ensure UserProfile.user is configuredStephen Finucane2018-12-22
| | | | | | | | | | 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
* Add REST API validation using OpenAPI schemaStephen Finucane2018-12-22
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* docs: Remove old Swagger 2.0 specStephen Finucane2018-12-22
| | | | | | | 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>
* docs: Store versioned OpenAPI schemasStephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Make API document versionedStephen Finucane2018-12-22
| | | | | | | | | | | | | | | 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>
* docs: Document the '/events' resourceStephen Finucane2018-12-22
| | | | | | | | 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>
* docs: Document the '/patches/{patch_id}/checks' resourceStephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Document the '/patch/{id}/comments' resourceStephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Document the '/covers/{id}/comments' resourceStephen Finucane2018-12-22
| | | | | | | 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>
* docs: Document the '/series' resourceStephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Document the '/patches' resourceStephen Finucane2018-12-22
| | | | | | The big one (TM). Nothing too odd here though. Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Document the '/covers' resourceStephen Finucane2018-12-22
| | | | | | | Again, we're adding embedded serializers before the main resource but that will come. Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Document the '/bundles' resourceStephen Finucane2018-12-22
| | | | | | | | | 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>
* docs: Document the '/projects' resourceStephen Finucane2018-12-22
| | | | | | This one's pretty straightforward. Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Document the '/people' resourceStephen Finucane2018-12-22
| | | | | | | | 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>
* docs: Document the '/users' resourceStephen Finucane2018-12-22
| | | | | | | 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>
* docs: Start documenting API using OpenAPIStephen Finucane2018-12-22
| | | | | | | | | | | | | | | 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>
* REST: Handle JSON requestsStephen Finucane2018-12-22
| | | | | | | | | | | | 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>
* tests: Use project.id in requests, not objectStephen Finucane2018-12-22
| | | | | | The object is not serializable. Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Use valid URLsStephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Start setting Project.listemailStephen Finucane2018-12-22
| | | | | | | | | 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>
* REST: Drop embedded bundle serializerStephen Finucane2018-12-22
| | | | | | This wasn't used anywhere and can therefore be removed. Signed-off-by: Stephen Finucane <stephen@that.guru>
* REST: Fix typo in embedded serializersStephen Finucane2018-12-22
| | | | | | | This was preventing the v1.1 fields from getting dropped as intended. Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #237
* REST: Handle unset seriesStephen Finucane2018-12-22
| | | | | | | | | | 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>
* signals: Fix 'series-completed' eventStephen Finucane2018-12-22
| | | | | | | | 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")
* tests: Add 'store_samples' decorator to 'test_event'Stephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Add tests for '/events' resourceStephen Finucane2018-12-22
| | | | | | This highlights an issue that will be resolved in a future change. Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Add 'store_samples' decorator to 'test_check'Stephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Add 'store_samples' decorator to 'test_comment'Stephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Add 'store_samples' decorator to 'test_series'Stephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Add 'store_samples' decorator to 'test_cover'Stephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Add 'store_samples' decorator to 'test_patch'Stephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Add 'store_samples' decorator to 'test_user'Stephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Add 'store_samples' decorator to 'test_people'Stephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Add 'store_samples' decorator to 'test_project'Stephen Finucane2018-12-22
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Add 'store_samples' decorator to 'test_bundle'Stephen Finucane2018-12-22
| | | | | | | | | 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>
* tests: Add 'store_samples' decoratorStephen Finucane2018-12-22
| | | | | | | | | 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>
* REST: Ensure submission exists for comment listingStephen Finucane2018-12-22
| | | | | Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #225
* REST: Ensure patch exists for check creationStephen Finucane2018-12-22
| | | | | Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #226