Skip to content

Conversation

fanminshi
Copy link
Contributor

@fanminshi fanminshi commented Aug 30, 2018

Implement and test the case where CA exists but Application secret doesn't. The CA generator should simply retrieve the CA asset from the cluster and uses it to create a new application TLS secret.

@fanminshi
Copy link
Contributor Author

fanminshi commented Aug 30, 2018

  • add test in this pr.

@fanminshi fanminshi mentioned this pull request Aug 30, 2018
10 tasks
@fanminshi fanminshi force-pushed the impl_tls_ca_not_app branch 2 times, most recently from a49da2c to 93ef3e2 Compare August 30, 2018 21:00
@fanminshi fanminshi changed the title [WIP] pkg/tlsutil: impl the case where CA exist but App secret doesn't *: implement and test the case where CA exists but App secret doesn't Aug 30, 2018
@fanminshi fanminshi force-pushed the impl_tls_ca_not_app branch 4 times, most recently from 589327c to 1e6450a Compare August 30, 2018 22:06
@fanminshi
Copy link
Contributor Author

cc/ @hasbro17 @shawn-hurley

@@ -0,0 +1,18 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I don't understand where this is used? Is it to generate the certs above after they expire? I think the same thing for the gencert.json, ca.csr, and ca-csr.json above.

Also, should we consider using testdata for the directory rather than fixtures?

Directory and file names that begin with "." or "_" are ignored by the go tool, as are directories named "testdata".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shawn-hurley it is used to generate CA key and Cert which is then used by my tests.

func init() {
	caCertBytes, err := ioutil.ReadFile("./fixtures/ca.crt")
	if err != nil {
		panic(err)
	}
	caConfigMap.Data = map[string]string{tlsutil.TLSCACertKey: string(caCertBytes)}
 	caKeyBytes, err := ioutil.ReadFile("./fixtures/ca.key")
	if err != nil {
		panic(err)
	}
	caSecret.Data = map[string][]byte{tlsutil.TLSPrivateCAKeyKey: caKeyBytes}
}

should we consider using testdata for the directory rather than fixtures?
sounds good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed! PTAL cc/ @shawn-hurley

@fanminshi fanminshi force-pushed the impl_tls_ca_not_app branch 2 times, most recently from 311e304 to d9878fb Compare August 31, 2018 18:24
"ca": {
"expiry": "87600h"
}
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave a newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@fanminshi fanminshi force-pushed the impl_tls_ca_not_app branch from d9878fb to a396ab1 Compare August 31, 2018 18:26
"expiry": "87600h"
}
}
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@fanminshi fanminshi force-pushed the impl_tls_ca_not_app branch from a396ab1 to bab166a Compare August 31, 2018 18:35
}
// check if appSecret returned from GenerateCert is the same as the one that exists in the k8s.
if !reflect.DeepEqual(appSecret, appSecretFromCluster) {
t.Fatalf("%+v differs %+v", appSecret, appSecretFromCluster)
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this error message to Expected: %+v \n Got: %+v. Otherwise it's not clear what was expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am going to use "expect %+v, but got %+v" to be consistent.

@fanminshi fanminshi force-pushed the impl_tls_ca_not_app branch from bab166a to a7bc2cd Compare August 31, 2018 18:42
Name: crName,
Namespace: namespace,
},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to make a helper for this, now or in a later PR, since we're using the dummy runtime object in all test cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I will do another round of refactoring after finishing all the test cases.

@fanminshi fanminshi force-pushed the impl_tls_ca_not_app branch from 6f93774 to fb40804 Compare August 31, 2018 18:56
@hasbro17
Copy link
Contributor

LGTM

@fanminshi fanminshi merged commit c30b06b into operator-framework:master Aug 31, 2018
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