-
-
Notifications
You must be signed in to change notification settings - Fork 147
[DXCDT-12] Use wiremock within custom domain verification test #501
Conversation
a5f5b3a
to
9b76d93
Compare
9b76d93
to
7a7ecd1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, this definitely pushes us forward and will empower others to contribute with confidence.
I've made a bunch of small comments, mostly around naming and clarity. However the one major point I'd like to explore is the abstraction of the provider initialization so that we don't need to declare the schema twice to accommodate two sets of configuration. Instead, I think it would be wise to have a single provider initialization function that accepted some configuration. That way we are only defining and updating that schema in a single place and we don't need to hardcode any configuration.
CONTRIBUTING.md
Outdated
@@ -40,11 +46,10 @@ AUTH0_CLIENT_ID=<your-auth0-client-id> | |||
AUTH0_CLIENT_SECRET=<your-auth0-client-secret> | |||
``` | |||
|
|||
Then, run `make testacc`. | |||
Then, run `docker-compose up -d && make testacc`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts about bundling the docker-compose up
directly into a separate command in the makefile? Perhaps make testacc_local
? The makefile does a good job of hiding away a lot of the implementation details and we don't want to require folks to need to know to run the docker compose locally.
However, this would just be for local invocation, I do like that it's separated in the Github workflow above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further, you're omitting the --build
arg here whereas it exists in the workflow, I forget if building the image is a default behavior of up
but would think that we'd want to be consistent in both places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can add a makefile command to bootstrap the dev env.
When docker-compose up
is ran and the image is not available on the host machine it will always default to building it. The --build
is there just to always force rebuilding and not use the one from cache.
|
||
**Note:** The acceptance tests make calls to a real Auth0 tenant, and create | ||
real resources. Certain tests, for example for custom domains | ||
(`TestAccCustomDomain`), also require a paid Auth0 subscription to be able to | ||
real resources. Certain tests also require a paid Auth0 subscription to be able to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we list which ones specifically so folks could know to expect those failing tests?
auth0/provider_test.go
Outdated
"github.com/hashicorp/terraform-plugin-sdk/terraform" | ||
|
||
"gopkg.in/auth0.v5/management" | ||
) | ||
|
||
func providerWithWiremock() *schema.Provider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While Wiremock is a testing utility we're using, it may not be descriptive at first glance. Would you consider something like providerWithMockedRequests
, mockedProvider
or something similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated it to providerWithTestingConfiguration
.
}, | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire function is awfully similar to the init
function in provider.go. It appears that the only differences are in configuration being passed in. Would you consider introducing a function that instantiates a provider with the configuration as an argument? Doing so would allow us to only need to instantiate and modify the provider schema in one location, as opposed to two for any modifications of resources. It would also mean that we don't need to hardcode the mocked service's host.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
resource.Test(t, resource.TestCase{ | ||
Providers: map[string]terraform.ResourceProvider{ | ||
"auth0": Provider(), | ||
"digitalocean": digitalocean.Provider(), | ||
"auth0": providerWithWiremock(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking my understanding here, this is the exact spot where we'd swap the real provider with the provider with mocked requests, when we adjust the tests going forward?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's correct:)
## Getting started | ||
|
||
To work on the provider, you'll need [Go](http://www.golang.org) installed on | ||
your machine (version 1.10+ is *required*). You'll also need to correctly setup | ||
your machine (version 1.13+ is *required*). You'll also need to correctly set up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is updated to 1.13 to support the usage of modules, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's the main reason I bumped it.
CONTRIBUTING.md
Outdated
## Prerequisites | ||
|
||
- [Go 1.13+](https://go.dev/) | ||
- [Docker](https://docs.docker.com/get-docker/) | ||
- [Docker-Compose](https://docs.docker.com/compose/install/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we framed these as dependencies for testing? Otherwise it may appear that docker and docker compose are fundamental to the contribution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well in a way they are fundamental to the contribution, to ensure that all tests are passing, or if we want to add new test cases for new functionality we will need the mocks as well.
Edit: Made it more clear tho that those are used within testing.
eefc558
to
b7096d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid work!
Proposed Changes
In this PR we are introducing a wiremock container in order for us to not rely on digital ocean directly for verifying custom domains with tests.
We will now have the potential to apply the same strategy to multiple tests, specially ones that might require paid subscriptions.
Acceptance Test Output
Community Note