| 1 |
|
| 2 |
|
| 3 |
package integration |
| 4 |
|
| 5 |
import ( |
| 6 |
"fmt" |
| 7 |
"testing" |
| 8 |
) |
| 9 |
|
| 10 |
var testdata = "testdata" |
| 11 |
|
| 12 |
type CertificateSignCmd struct { |
| 13 |
name string |
| 14 |
command CLICommand |
| 15 |
csr string |
| 16 |
issuerCrt string |
| 17 |
issuerKey string |
| 18 |
pass string |
| 19 |
} |
| 20 |
|
| 21 |
func (k CertificateSignCmd) setPass(pass string) CertificateSignCmd { |
| 22 |
return CertificateSignCmd{k.name, k.command, k.csr, k.issuerCrt, k.issuerKey, pass} |
| 23 |
} |
| 24 |
|
| 25 |
func (k CertificateSignCmd) fail(t *testing.T, expected string) { |
| 26 |
k.command.fail(t, k.name, expected, "") |
| 27 |
} |
| 28 |
|
| 29 |
func (k CertificateSignCmd) failNoPass(t *testing.T, expected string) { |
| 30 |
k.command.fail(t, k.name, expected, "") |
| 31 |
} |
| 32 |
|
| 33 |
func NewCertificateSignCmd(name, csr, crt, key string) CertificateSignCmd { |
| 34 |
csrFile := fmt.Sprintf("%s/%s", testdata, csr) |
| 35 |
crtFile := fmt.Sprintf("%s/%s", testdata, crt) |
| 36 |
keyFile := fmt.Sprintf("%s/%s", testdata, key) |
| 37 |
command := NewCLICommand().setCommand(fmt.Sprintf("step certificate sign %s %s %s", |
| 38 |
csrFile, crtFile, keyFile)) |
| 39 |
return CertificateSignCmd{name, command, csrFile, crtFile, keyFile, "password"} |
| 40 |
} |
| 41 |
|
| 42 |
func TestCertificateSign(t *testing.T) { |
| 43 |
NewCertificateSignCmd("bad-sig", "certificate-create-bad-sig.csr", "intermediate_ca.crt", "intermediate_ca_key").failNoPass(t, "Certificate Request has invalid signature: crypto/rsa: verification error\n") |
| 44 |
|
| 45 |
} |