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

Exercise connections, etc. in zone tests #45

Merged
merged 18 commits into from
Jun 12, 2019
Merged

Exercise connections, etc. in zone tests #45

merged 18 commits into from
Jun 12, 2019

Conversation

mdb
Copy link
Contributor

@mdb mdb commented Jun 4, 2019

This PR seeks to exercise more functionality in the zone resource tests towards the goal of more robust testing and addressing issue #21.

@mdb mdb changed the title [WIP] Exercise connections, etc. in zone tests Exercise connections, etc. in zone tests Jun 5, 2019
zConName = "vinyldns."
zConKey = "nzisn+4G2ldMn0q1CV3vsg=="
zConKeyName = "vinyldns."
zConPrimaryServer = "vinyldns-bind9"
Copy link

@rhenning rhenning Jun 10, 2019

Choose a reason for hiding this comment

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

If I understand the spec correctly, then I believe that a fully qualified domain name, IP address, or IPAddr:Port pair would more clearly communicate the type of data desired for primary server. While a simple unqualified host name might work, it seems like an uncommon case. https://www.vinyldns.io/api/zone-model.html#zone-conn-attr

Copy link
Contributor Author

@mdb mdb Jun 10, 2019

Choose a reason for hiding this comment

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

@rhenning Are you referring to vinyldns-bind9? If so, I agree, but this is the docker-compose service name. If it's not clear, these acceptance tests are running against a docker-compose'd VinylDNS setup so I believe it must be vinyldns-bind9, IIUC.

Choose a reason for hiding this comment

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

@rhenning just the host name OR the IP address is the common case, as 99% of DNS servers talk on port 53. Actually, having the port specifier is the uncommon case (because you cannot bind to lower ports on most linux machines) and we need to do uncommon things for our tests

Choose a reason for hiding this comment

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

Got it. I hadn't realized that the tests were running against a docker-compose container. Totally makes sense why it's an unqualified hostname now. Disregard last transmission!

zConKey = "nzisn+4G2ldMn0q1CV3vsg=="
zConKeyName = "vinyldns."
zConPrimaryServer = "vinyldns-bind9"
// NOTE: If ever the test config HCL is changed, these zACLRule*Hash var

Choose a reason for hiding this comment

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

test config "ACL"?

Choose a reason for hiding this comment

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

HCL is "Hashicorp Configuration Language" - The Terraform DSL itself.

resource.TestCheckResourceAttr("vinyldns_zone.test_zone", "name", zName),
resource.TestCheckResourceAttr("vinyldns_zone.test_zone", "email", zEmail),
resource.TestCheckResourceAttr("vinyldns_zone.test_zone", "zone_connection.0.name", zConName),
resource.TestCheckResourceAttr("vinyldns_zone.test_zone", "zone_connection.0.key", zConKey),

Choose a reason for hiding this comment

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

fun facts, when hitting a "real" environment (not docker), the key is encrypted. I.e., it is impossible to verify the value of the key in a test against a real environment unless you know the secret and the encryption algorithm, so very likely not.

This works against docker because the default cryptography is NoOp


accessLev := rs.Attributes[fmt.Sprintf("acl_rule.%s.access_level", zACLRuleUpdatedHash)]
if accessLev != "Delete" {
return fmt.Errorf("expected acl_rule access_level attribute to have value; got %s from state: %s", accessLev, rs.Attributes)

Choose a reason for hiding this comment

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

this error message is a little off yea? "expected acl_rule access_level attribute to have value Delete; got ...."

It indicates that it doesn't have a value, but the if check is whether it is Delete

Copy link

@pauljamescleary pauljamescleary left a comment

Choose a reason for hiding this comment

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

A few small comments, looks good!

@mdb
Copy link
Contributor Author

mdb commented Jun 11, 2019

@pauljamescleary @rhenning Thanks for the feedback!
@pauljamescleary I pushed a commit to improve the error messaging typo you pointed out.

@mdb mdb merged commit ba2ddf0 into master Jun 12, 2019
@mdb mdb deleted the exercise-connections branch June 12, 2019 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants