Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1693 api v3 disabled fails validation #2066

Merged
merged 103 commits into from
May 31, 2022

Conversation

dk1844
Copy link
Contributor

@dk1844 dk1844 commented May 16, 2022

Implementation of PR review #2055 (comment), specifically:

  • disallow all PUT/POST calls except for PUT on /{name} to enable.
  • validate should return error disabled so it cannot be run in spark-jobs.

It has its own PR, because there are a lot of changes in the end (introducing VersionedModelServiceV3 - and changing some abstract classes to traits in order to multi-inherit in specific services both from VersionedModelServiceV3 (API V3 backing) and from V2 services that already hold a lot of reusable implementation.

Partial for #1693

dk1844 added 30 commits March 7, 2022 15:35
…e contours, empty DatasetControllerV3 to test
 - login allowed at /api/login & /api-v3/login
 - v2/v3 BaseRestApiTest distinquished
…st and post-import + IT to prove correct behavior
…mport + IT to prove correct behavior - fix with common location processing with segment stripping (+normalization)
…ion} now works for # or 'latest' (IT = regression test)
…{name}/{version} and /{name}/latest - improved
…- supports latest for as version-expression, impl for datasets improved by actual existence checking + IT test cases for non-existing/non-latest queries
…properties - supports latest for as version-expression; get impl is unvalidated, put impl checks validity

 - login is now common, under /api/login for both v2 and v3 (did not work previously)
…properties - supports latest for as version-expression; get impl is unvalidated, put impl checks validity - extended for different validation cases

 - login is now common, under /api/login for both v2 and v3 (did not work previously)
…ture -> CompletableFuture (mistake reverted)
… added. IT mostly adjusted, but there are todos

 - DatasetServiceV3 introduced to carry difference in behavior to DatasetService. original entity validation has been divided into create-validation and regular-entity validation.
 - buildfix for VersionedModelServiceTest
…asets/dsName/version/rules, GET datasets/dsName/version/rules/# + IT
 - v2 ignores this added information
 - needs
}

// v3 has internal validation on importItem (because it is based on update), v2 only had it on import
override def importSingleItem(item: C, username: String, metadata: Map[String, String]): Future[Option[(C, Validation)]] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the metadata passed here?

Copy link
Contributor Author

@dk1844 dk1844 May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing and making me realizing the problem! 🙇‍♂️
The metadata is passed there, because it should have been checked, too, but this implementation failed to do so.

Should be fixed now, I have updated the code and added test cases for both V2 and V3 import API to hold this together.

Base automatically changed from feature/1693-api-v3-delete-recreate to develop-ver-3.0 May 24, 2022 09:44
…s-validation

% Conflicts:
%	rest-api/src/main/scala/za/co/absa/enceladus/rest_api/controllers/v3/VersionedModelControllerV3.scala
%	rest-api/src/main/scala/za/co/absa/enceladus/rest_api/exceptions/EndpointDisabled.scala
%	rest-api/src/main/scala/za/co/absa/enceladus/rest_api/exceptions/EndpointDisabledException.scala
%	rest-api/src/main/scala/za/co/absa/enceladus/rest_api/exceptions/EntityDisabledException.scala
%	rest-api/src/main/scala/za/co/absa/enceladus/rest_api/services/DatasetService.scala
%	rest-api/src/main/scala/za/co/absa/enceladus/rest_api/services/PropertyDefinitionService.scala
%	rest-api/src/main/scala/za/co/absa/enceladus/rest_api/services/VersionedModelService.scala
%	rest-api/src/main/scala/za/co/absa/enceladus/rest_api/services/v3/DatasetServiceV3.scala
%	rest-api/src/main/scala/za/co/absa/enceladus/rest_api/services/v3/MappingTableServiceV3.scala
%	rest-api/src/main/scala/za/co/absa/enceladus/rest_api/services/v3/PropertyDefinitionServiceV3.scala
%	rest-api/src/test/scala/za/co/absa/enceladus/rest_api/integration/controllers/v3/DatasetControllerV3IntegrationSuite.scala
%	rest-api/src/test/scala/za/co/absa/enceladus/rest_api/integration/controllers/v3/MappingTableControllerV3IntegrationSuite.scala
Copy link
Contributor

@AdrianOlosutean AdrianOlosutean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, code review

@sonarcloud
Copy link

sonarcloud bot commented May 27, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 11 Code Smells

No Coverage information No Coverage information
2.5% 2.5% Duplication

Copy link
Contributor

@AdrianOlosutean AdrianOlosutean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AdrianOlosutean AdrianOlosutean added the PR:reviewing Only for PR - PR is being reviewed by somebody; blocks merging label May 30, 2022
Copy link
Contributor

@AdrianOlosutean AdrianOlosutean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing the API and I think DatasetControllerV3 should also have this validation on updating the properties: PUT on"/{name}/{version}/properties"

@AdrianOlosutean AdrianOlosutean removed the PR:reviewing Only for PR - PR is being reviewed by somebody; blocks merging label May 30, 2022
@dk1844
Copy link
Contributor Author

dk1844 commented May 31, 2022

I was testing the API and I think DatasetControllerV3 should also have this validation on updating the properties: PUT on"/{name}/{version}/properties"

What do you mean? DatasetServiceV3.updateProperties() does validate properties being updated. Which part of validation do you consider missing, @AdrianOlosutean ?

@AdrianOlosutean
Copy link
Contributor

When I tested this endpoint on a disabled dataset, I didn't see the disabled validation

I was testing the API and I think DatasetControllerV3 should also have this validation on updating the properties: PUT on"/{name}/{version}/properties"

What do you mean? DatasetServiceV3.updateProperties() does validate properties being updated. Which part of validation do you consider missing, @AdrianOlosutean ?

@dk1844
Copy link
Contributor Author

dk1844 commented May 31, 2022

When I tested this endpoint on a disabled dataset, I didn't see the disabled validation

I was testing the API and I think DatasetControllerV3 should also have this validation on updating the properties: PUT on"/{name}/{version}/properties"

What do you mean? DatasetServiceV3.updateProperties() does validate properties being updated. Which part of validation do you consider missing, @AdrianOlosutean ?

I can see this covered in the (passing) integTests:
direct file
diff view

Copy link
Contributor

@Zejnilovic Zejnilovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build, run, code review

@Zejnilovic Zejnilovic added the PR:tested Only for PR - PR was tested by a tester (person) label May 31, 2022
Copy link
Contributor

@AdrianOlosutean AdrianOlosutean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally as well

@dk1844 dk1844 merged commit 9cf521e into develop-ver-3.0 May 31, 2022
@dk1844 dk1844 deleted the feature/1693-api-v3-disabled-fails-validation branch May 31, 2022 13:13
@dk1844 dk1844 linked an issue Jun 7, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR:tested Only for PR - PR was tested by a tester (person)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Experimental API 3 - Versioned Model
3 participants