-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd: Align TLS options with hydra (#114)
Signed-off-by: Frederic BIDON <[email protected]>
- Loading branch information
Showing
4 changed files
with
312 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
/* | ||
* Copyright © 2017-2018 Aeneas Rekkas <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @author Aeneas Rekkas <[email protected]> | ||
* @copyright 2017-2018 Aeneas Rekkas <[email protected]> | ||
* @license Apache-2.0 | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestHelperGetTLSCertAndKey(t *testing.T) { | ||
certFixture := `LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVFRENDQXZpZ0F3SUJBZ0lKQU5mK0lUMU1HaHhCTUEwR0NTcUdTSWI` + | ||
`zRFFFQkN3VUFNSU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bcvfiprLqhGKA5H7hJTfDpRzYlArnfi2LAgMBAAGjbjBsMAkGA1UdEwQCMAAw | ||
CwYDVR0PBAQDAgXgMFIGA1UdEQRLMEmCHm9hdGhrZWVwZXIub25lY29uY2Vybi10 | ||
ZXN0LmNvbYInYXBpLXNlcnZpY2UtcHJveGllZC5vbmVjb25jZXJuLXRlc3QuY29t | ||
MA0GCSqGSIb3DQEBCwUAA4IBAQB1Pbl+RmntEoclyjYzsykKoiXs3pa83CgDZ6pC | ||
grv4LQxSoEfJ04f8bD4IIYFGCZfVNG0VpEXrNlk6UbsVdTABtqCguJTWwDGUAh6X | ||
3bFhrZnPexs//QwgDAdqIf0EgwcDUG76GIdfk70e1Zuxchxd8UBCpAIdeU08vVky | ||
4PWv2K4aD4FjChKxCN5khN50FMPcaI+xVgd47tPhVN9lQioGDChsT5vARk7ba/ce | ||
0Q9NWdiMfLEgLdcBobZKFtFrlKtyzOgDjLvXvLQs/s2merSI9fkwoOBEP+7j7Zns | ||
Ajy9MfhwqbTpW7KpCSFa0VT/2u95ZRcPvrXldKRygB4WuARr | ||
-----END CERTIFICATE-----` | ||
keyFileContent := `-----BEGIN RSA PRIVATE KEY----- | ||
MIIEpAIBAAKCAQEA1ltSQb6cf6HxdM/+Acvm4AKfoW8qp1JQmoG4oMTjy7+4h/DP | ||
rtw+g3iGNwu3VimjeIGrxsEv+6+EJViIKPjjA7ed5zXeaIy/+X/RkOHXTZp8KJw8 | ||
RVPJMGC2AyzQRwto99QOUp8c+CknUzOxYOPDyMtwImhdhw6g2FUYmRGayMUq0iWi | ||
X7l3gSBAKT4j5h/QzZZelGe/OqH/iGHilnp3Av5YzoYiCa1f7A3u+gEHLr/TqFoh | ||
myBU0tly0Q2rXNKwMVb0GzbN8ohG/MEtGRgMatJ3zotH3Wjx/OxLJy7yY2TTqq/z | ||
EiJwG3L34qay6oRigOR+4SU3w6Uc2JQK534tiwIDAQABAoIBAQDOlrDOQCCgObl1 | ||
9Uc+//8BAkZK1dLr879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aECgYA0Zkwy9z1Ws4ANjG+YlaUxpKLcJFdyCHKdFr65WYsmGqNkJfGSGeB6 | ||
RHMZNMoDTRhmhQhj8M7N+FMtZAUOMddZ/1cvREtFW7+66w+XZvj9CQ/uectp/qb+ | ||
6dnObrdmLiZ+U/NzGLKmFgJTc9X7fwm11PSliZK0WrdnXKnzkh9OhQ== | ||
-----END RSA PRIVATE KEY-----` | ||
tmpCertFile, _ := ioutil.TempFile("", "test-cert") | ||
tmpCert := tmpCertFile.Name() | ||
tmpKeyFile, _ := ioutil.TempFile("", "test-key") | ||
tmpKey := tmpKeyFile.Name() | ||
defer func() { | ||
_ = os.Remove(tmpCert) | ||
_ = os.Remove(tmpKey) | ||
}() | ||
_ = ioutil.WriteFile(tmpCert, []byte(certFileContent), 0600) | ||
_ = ioutil.WriteFile(tmpKey, []byte(keyFileContent), 0600) | ||
initConfig() | ||
|
||
// 1. no TLS | ||
os.Setenv("HTTP_TLS_KEY_PATH", "") | ||
os.Setenv("HTTP_TLS_CERT_PATH", "") | ||
os.Setenv("HTTP_TLS_KEY", "") | ||
os.Setenv("HTTP_TLS_CERT", "") | ||
cert, err := getTLSCertAndKey() | ||
assert.Nil(t, cert) | ||
assert.NoError(t, err) | ||
|
||
// 2. inconsistent TLS (i): warning only | ||
os.Setenv("HTTP_TLS_KEY_PATH", "x") | ||
os.Setenv("HTTP_TLS_CERT_PATH", "") | ||
os.Setenv("HTTP_TLS_KEY", "") | ||
os.Setenv("HTTP_TLS_CERT", "") | ||
cert, err = getTLSCertAndKey() | ||
assert.Nil(t, cert) | ||
assert.NoError(t, err) | ||
|
||
// 2. inconsistent TLS (ii): warning only | ||
os.Setenv("HTTP_TLS_KEY_PATH", "") | ||
os.Setenv("HTTP_TLS_CERT_PATH", "") | ||
os.Setenv("HTTP_TLS_KEY", "") | ||
os.Setenv("HTTP_TLS_CERT", "x") | ||
cert, err = getTLSCertAndKey() | ||
assert.Nil(t, cert) | ||
assert.NoError(t, err) | ||
|
||
// 3. invalid TLS file | ||
os.Setenv("HTTP_TLS_KEY_PATH", "x") | ||
os.Setenv("HTTP_TLS_CERT_PATH", tmpCert) | ||
os.Setenv("HTTP_TLS_KEY", "") | ||
os.Setenv("HTTP_TLS_CERT", "") | ||
cert, err = getTLSCertAndKey() | ||
assert.Nil(t, cert) | ||
assert.Error(t, err) | ||
|
||
// 4. invalid TLS string (i) | ||
os.Setenv("HTTP_TLS_KEY_PATH", "") | ||
os.Setenv("HTTP_TLS_CERT_PATH", "") | ||
os.Setenv("HTTP_TLS_KEY", "{}") | ||
os.Setenv("HTTP_TLS_CERT", certFixture) | ||
cert, err = getTLSCertAndKey() | ||
assert.Nil(t, cert) | ||
assert.Error(t, err) | ||
|
||
// 4. invalid TLS string (ii) | ||
os.Setenv("HTTP_TLS_KEY_PATH", "") | ||
os.Setenv("HTTP_TLS_CERT_PATH", "") | ||
os.Setenv("HTTP_TLS_KEY", keyFixture) | ||
os.Setenv("HTTP_TLS_CERT", "{}") | ||
cert, err = getTLSCertAndKey() | ||
assert.Nil(t, cert) | ||
assert.Error(t, err) | ||
|
||
// 5. valid TLS files | ||
os.Setenv("HTTP_TLS_KEY_PATH", tmpKey) | ||
os.Setenv("HTTP_TLS_CERT_PATH", tmpCert) | ||
os.Setenv("HTTP_TLS_KEY", "") | ||
os.Setenv("HTTP_TLS_CERT", "") | ||
cert, err = getTLSCertAndKey() | ||
assert.NotNil(t, cert) | ||
assert.NoError(t, err) | ||
|
||
// 6. valid TLS strings | ||
os.Setenv("HTTP_TLS_KEY_PATH", "") | ||
os.Setenv("HTTP_TLS_CERT_PATH", "") | ||
os.Setenv("HTTP_TLS_KEY", keyFixture) | ||
os.Setenv("HTTP_TLS_CERT", certFixture) | ||
cert, err = getTLSCertAndKey() | ||
assert.NotNil(t, cert) | ||
assert.NoError(t, err) | ||
|
||
// 7. invalid TLS file content | ||
os.Setenv("HTTP_TLS_KEY_PATH", keyFixture) | ||
os.Setenv("HTTP_TLS_CERT_PATH", certFixture) | ||
os.Setenv("HTTP_TLS_KEY", "") | ||
os.Setenv("HTTP_TLS_CERT", "") | ||
cert, err = getTLSCertAndKey() | ||
assert.Nil(t, cert) | ||
assert.Error(t, err) | ||
|
||
// 8. invalid TLS string content | ||
os.Setenv("HTTP_TLS_KEY_PATH", "") | ||
os.Setenv("HTTP_TLS_CERT_PATH", "") | ||
os.Setenv("HTTP_TLS_KEY", keyFileContent) | ||
os.Setenv("HTTP_TLS_CERT", certFileContent) | ||
cert, err = getTLSCertAndKey() | ||
assert.Nil(t, cert) | ||
assert.Error(t, err) | ||
|
||
// 9. mismatched TLS file content | ||
os.Setenv("HTTP_TLS_KEY_PATH", certFileContent) | ||
os.Setenv("HTTP_TLS_CERT_PATH", keyFileContent) | ||
os.Setenv("HTTP_TLS_KEY", "") | ||
os.Setenv("HTTP_TLS_CERT", "") | ||
cert, err = getTLSCertAndKey() | ||
assert.Nil(t, cert) | ||
assert.Error(t, err) | ||
|
||
// 10. mismatched TLS string content | ||
os.Setenv("HTTP_TLS_KEY_PATH", "") | ||
os.Setenv("HTTP_TLS_CERT_PATH", "") | ||
os.Setenv("HTTP_TLS_KEY", certFixture) | ||
os.Setenv("HTTP_TLS_CERT", keyFixture) | ||
cert, err = getTLSCertAndKey() | ||
assert.Nil(t, cert) | ||
assert.Error(t, err) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters