Commit Graph

15 Commits

Author SHA1 Message Date
Felipe Monteiro b03a4522cb fix: Use schema instead of metadata.schema for replacement check
Recently added replacement check incorrectly uses metadata.schema
and metadata.name to key on the document -- but it should be schema
and metadata.name, the combination of which uniquely defines a
document.

Change-Id: I6cd1679ad41be38cb78d65ce2763e60f7da390d2
2018-10-31 15:02:28 -04:00
Felipe Monteiro 035841416b Validate bucket diffing works with revision rollback
Adds a unit test to validate following scenario:

1) create revision 1 with document
2) create revision 2 with no documents
3) rollback to revision 1 (creating revision 3)

Validate that diffing works for rolled-back revision.
All cases above use same bucket.

Also refactors some test logic for neatness.

Change-Id: I71bf7d34e8aae3ad5abb3c53b05cb96a7038ddc2
2018-10-18 19:07:42 +01:00
Felipe Monteiro 1264e5af6c Document replacement: Update Document unique constraint
This updates the unique constraint for Document model from
schema/metadata.name to schema/metadata.name/layer which is
a pre-requisite for document replacement implementation.

The remainder fo the changes are taken of in child PS
(particulary those related to the layering module):
https://review.gerrithub.io/#/c/403888/

Change-Id: Icc4f4960b3a3951f649c7886dbe0bce77341a9f7
2018-03-28 17:08:03 -04:00
Felipe Monteiro 89cc04165c Remove dead validation policy code.
This PS removes dead validation policy code from Deckhand. Most
of this code is just for testing and serves no purpose because
Deckhand currently doesn't offer support for validation policies.
Besides, these tests assume a wrong implementation of validation
policies and should be removed for that reason alone.

The actual documentation and rudimentary foundational logic
for implementing validation policies has been left undeleted.
(Some of this logic includes having a constant for validation
policies in deckhand.types and a schema for validating validation
policies).

Change-Id: Ie0d27dae84c82096e0a88bebcba9bb7ca9bee7c1
2018-01-07 21:59:23 -04:00
Felipe Monteiro 16c7ec196f Implement sort filter
This PS implements the sort filter, allowing (for now)
the GET /revisions and GET /revision/{revision_id}/documents
endpoints to be sorted as per the API documentation in
Deckhand [0].

An additional filter has also been added to the 2 aforementioned
endpoints as well -- order -- which determines the order in
which sorted results are returned: "asc" for ascending
order and "desc" for descending order.

[0] http://deckhand.readthedocs.io/en/latest/api_ref.html#get-revisions-revision-id-documents

Change-Id: Ifb9e15b8379b0a28889a14c331d81d9a4147f1d4
2017-11-29 20:53:21 +00:00
Felipe Monteiro d941b09ef0 Reset primary key back to 1 after deleting all revisions
This PS resets the primary key for each table in the
database back to 1 after deleting all revisions
(i.e. DELETE /revisions) which effectively purges all
the data in the database.

Change-Id: Id64e01ea85d7098e261a56cf9eacdcce716b1f48
2017-11-25 05:40:58 +00:00
Felipe Monteiro ef4f65037d Revision diffing API.
This commit implements revision diffing API and the
required back-end logic needed to realize it.

Included in this commit:

  - implementation of revision diffing
  - unskip all revision diff functional tests
  - add additional functional tests for revision diffing
  - relevant unit tests
  - document comparison is performed using hashing as opposed
    to more inefficient, direct comparisons

Change-Id: I0419ee9b8cf3fca6fe75818615d2338dc00b1003
2017-09-25 21:58:30 +01:00
Felipe Monteiro e32a5a9319 Bucket deletion implementation
This commit implements logic to realize bucket deletion. This
commit also adds logic for raising an exception when trying
to create the same (document.schema, document.metadata.name)
in a different bucket than the one it was originally created in.

Included in this commit:

  - Implementation of document deletion logic.
  - Documents are always saved, even if they have been deleted
    or remain unchanged between revisions. This makes it easier
    to compute the diff between revisions.
  - Associated unit tests.
  - Unskip all remaining functional tests for
    'document-crud-success-single-bucket.yaml`
  - Raise a 409 exception when trying to create the same
    (document.schema, document.metadata.name) in a different
    bucket.
  - Unskip functional tests for
    'document-crud-error-bucket-conflict.yaml'

Change-Id: I6693bbb918cb672de315a66bb087de547df302d1
2017-09-18 23:03:38 +01:00
Felipe Monteiro 7e5bb07541 Document buckets - update logic
Implement update logic for document buckets. Relevant functional
tests for a single bucket now pass.

Also removed validation policy DB model to simplify things.

Change-Id: Icd27cae1d2212a24604eb879518d0bd6974cdc9e
2017-09-07 20:48:57 +01:00
Felipe Monteiro c19309f347 Initial implementation of buckets
This commit adds endpoints for:

  * DELETE /revisions
  * PUT /bucket/{{bucket_name}}/revisions

Included in this commit:

  * Initial DB code for buckets
  * Initial API code for API buckets
  * Refactored unit tests to work with buckets
  * Passing *some* functional tests for:
    - revision-crud-success-single-bucket (*all*)
    - document-crud-success-single-bucket (*some*)
  * Corrected document view for list and corrected
    loads in MultidocJsonpaths for test_gabbi to not
    fix up the response body

Change-Id: Idf941591d24804b77441ab84259f8b7063c88a33
2017-08-24 20:58:26 +01:00
Felipe Monteiro 6e2238c3d8 Fix flake8 errors
This commit fixes flake8 errors and fixes a minor bug related to
a schema version being v1 rather than v1.0.

OpenStack hacking rules are used to pin down flake8 to sane
standards using [0].

[0] 06e676c461/test-requirements.txt (L5)

Change-Id: Ib236df6f5ec9505c0e635f0faa9877d3397a2e55
2017-08-14 20:48:14 +01:00
Felipe Monteiro e1446bb9e1 [feat] DECKHAND-28: Document pre-validation logic and API integration
This commit constitutes 1 of 2 monolithic ports from Github.
The following major changes have been made:

  - Created schemas for validating different types of documents
    (control and document schemas), including:
    * certificate key
    * certificate
    * data schema
    * document
    * layering policy
    * passphrase
    * validation policy
  - Implemented pre-validation logic which validates that each
    type of document conforms to the correct schema specifications
  - Implemented views for APIs -- this allows views to change the
    DB data to conform with API specifications
  - Implemented relevant unit tests
  - Implement functional testing foundation

Change-Id: I83582cc26ffef91fbe95d2f5f437f82d6fef6aa9
2017-08-08 18:52:44 +01:00
Felipe Monteiro 6299c4b123 Add view abstraction layer for modifying DB data into view data. 2017-07-31 20:08:38 +01:00
Felipe Monteiro 841906a435 Updated /GET revisions response body. 2017-07-31 17:01:40 +01:00
Felipe Monteiro 0608801376 Add endpoint for GET /revisions. 2017-07-30 23:28:25 +01:00