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/add integration tests #54

Merged
merged 102 commits into from
Oct 12, 2018
Merged

Feature/add integration tests #54

merged 102 commits into from
Oct 12, 2018

Conversation

dikhan
Copy link
Owner

@dikhan dikhan commented Sep 10, 2018

Proposed changes

Major refactoring to improve code quality and increase confidence when releasing code by adding a full fledge suit of integration tests.

  • Updated OpenAPI plugin side code to depend on interfaces so different implementation can be supplied. At the moment only OpenAPI v2 implementation is available but this refactoring prepares the field for future OpenAPI v3 support.
  • This change also reduces the ramp up time needed to learn the code structure making it easier for contributors to be able to contribute to development of new features.

Type of change

What type of change does your code introduce to the provider? Please put an x (w/o heading/trailing white spaces)
in the boxes that apply:

  • Bug-fix (change that fixes current functionality)
  • [] New feature (change that adds new functionality)
  • Enhancement (change that improves the code quality)

Checklist

Please put an x (w/o heading/trailing white spaces) in the boxes that apply:

  • I have read and followed the CONTRIBUTING guidelines
  • I have made sure code compiles correctly
  • I have run 'make test' locally from the terraform_provider_api folder and no errors were found
  • I have added tests that prove my fix is effective or that my feature works
  • I have added/updated necessary documentation (if appropriate)

adding integration tests
- improved quality code by having the OpenAPI Terraform provider rely on
interfaces to set up the provider factory and resource factory. This allows
for different implementations to be used such as OpenAPI v2 and make the
provider evolve seamlessly without any major change in the core code of
the provider by setting up the provider with any specific implementation.
- created openapi v2 implementation compliant with openapi spec interfaces
- provider now uses an OpenAPI Client which is able to send http requests
to the appropriate resource using the resource operation configuration
(e,g: security, parameters, etc)

TODO: need to fix the unit tests
- SpecSecurityDefinition should contain both sec def name and apikey name
which will be used in the API calls to properly send the correct header name
- specV2Analyser was not being init with the openAPIDocumentURL
- plugin service configuration was not being initialised with correct
skipVerify value
- add hostURL validation in case it's empty
- various field name renaming
- make APIProvider accept providerName instead of figuring out the value
inside...this enables the file to be unit tested and also integration
tests can be set up more easily

- dep ensure --add github.com/hashicorp/logutils and github.com/davecgh/go-spew
for integration tests
- fix bug in PUT cdn API where newCDN overriding previoys existing cdn
will not contain the id...doing a full copy of the cdn stored in the db now
updated with the info coming from the request payload (with the new fields values)
- updates to force new properties
- wrong api key auth value is provided
@dikhan dikhan self-assigned this Sep 10, 2018
- add pointer to provider client as now the clientOpenAPI interface is used in resource factory instead
- update resource factory to use clientOpenAPI interface instead
- update integration test to cast to clientOpenAPI interface
…e file

- added helper methods to ease the creation of spec definition property structs
- create SchemaDefinitionProperty type
dikhan added 27 commits October 5, 2018 08:55
- fix bug where object type props where not being tagged as typeObject
causing lots of weird behaviours
- attach maps to payload when object types are at play
- updated exaples with support for object types and status object tyeps (coming)
- use array of properties instead of map. this avoid issues where map key
is set but the property name is not
- this supports both status being on the root level of the schema definition and
status being in nested object types
- make use of idDefaultPropertyName instead of hardcoded string
- fix bug where status ids were not set properly (but rather immutable field)
- updated documentation
- use newStatus object type property instead of former string status
to validate object types as well as status fields of type object work
as expected
- update int tests to check on new status field instead
- update example swagger to not specify host. this simplifies int tests
and enables the example container to communicate correctly with the API
using the plugin config host set up
- update terraform-provider-openapi.yaml example plugin configuration swaggercodegen
swagger-url value to not use the port as mapping between external host port
and internal container app https port were different and was causing connection
refuse issues...hence just using https default ports which inside the container
resolves correctly to port 443 and API calls are made correclty from the example
container to the API swaggercodegen container
- refactor int test provider to use fix host where the API is meant to be
running ("https://localhost:8443/swagger.yaml"). No longer using the local
file since API is supposed to serve the swagger

More info at issue: #62
- PluginConfigSchemaV1
- specV2Analyser
- SpecSecuritySchemes
- created specStubAuthenticator
- added constructor newStubBackendConfiguration
- do not debug headers as they may contain secrets
- small refactor getServiceConfiguration removing non needed return params
and rename the function to be more specific
- renamed ProviderOpenAPI constructor
- unit tests shouod used their own test data instead of sharing to avoid
collisions or weird behaviours
@dikhan dikhan merged commit c32081d into master Oct 12, 2018
@dikhan dikhan deleted the feature/add-integration-tests branch October 12, 2018 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant