Fixed config files and trust manager tests to point at new fixtures

Signed-off-by: Diogo Monica <diogo@docker.com>
This commit is contained in:
Diogo Monica 2015-07-15 19:46:57 -07:00
parent cdee810942
commit d743dfac6e
5 changed files with 39 additions and 39 deletions

View File

@ -216,10 +216,10 @@ func testAddListTarget(t *testing.T, rootType data.KeyAlgorithm) {
err = repo.Initialize(rootCryptoService)
assert.NoError(t, err, "error creating repository: %s", err)
// Add fixtures/ca.cert as a target. There's no particular reason
// Add fixtures/intermediate-ca.crt as a target. There's no particular reason
// for using this file except that it happens to be available as
// a fixture.
latestTarget, err := NewTarget("latest", "../fixtures/ca.cert")
latestTarget, err := NewTarget("latest", "../fixtures/intermediate-ca.crt")
assert.NoError(t, err, "error creating target")
err = repo.AddTarget(latestTarget)
assert.NoError(t, err, "error adding target")
@ -253,7 +253,7 @@ func testAddListTarget(t *testing.T, rootType data.KeyAlgorithm) {
changelistDir.Close()
// Create a second target
currentTarget, err := NewTarget("current", "../fixtures/ca.cert")
currentTarget, err := NewTarget("current", "../fixtures/intermediate-ca.crt")
assert.NoError(t, err, "error creating target")
err = repo.AddTarget(currentTarget)
assert.NoError(t, err, "error adding target")

View File

@ -25,5 +25,5 @@ RUN go install github.com/docker/notary/cmd/notary-signer
EXPOSE 4443
#ENTRYPOINT rufus -cert /go/src/github.com/docker/notary/fixtures/rufus.pem -key /go/src/github.com/docker/notary/fixtures/rufus.key -debug -pkcs11 /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so -pin 123456
ENTRYPOINT notary-signer -cert /go/src/github.com/docker/notary/fixtures/rufus.pem -key /go/src/github.com/docker/notary/fixtures/rufus.key -debug -pkcs11 $LIBDIR/libsofthsm2.so -pin 1234
#ENTRYPOINT notary-signer -cert /go/src/github.com/docker/notary/fixtures/notary-signer.pem -key /go/src/github.com/docker/notary/fixtures/notary-signer.key -debug -pkcs11 /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so -pin 123456
ENTRYPOINT notary-signer -cert /go/src/github.com/docker/notary/fixtures/notary-signer.pem -key /go/src/github.com/docker/notary/fixtures/notary-signer.key -debug -pkcs11 $LIBDIR/libsofthsm2.so -pin 1234

View File

@ -14,8 +14,8 @@ func TestRunBadAddr(t *testing.T) {
err := Run(
context.Background(),
"testAddr",
"../fixtures/ca.pem",
"../fixtures/ca-key.pem",
"../fixtures/notary-server.pem",
"../fixtures/notary-server.key",
signed.NewEd25519(),
"",
nil,
@ -31,8 +31,8 @@ func TestRunReservedPort(t *testing.T) {
err := Run(
ctx,
"localhost:80",
"../fixtures/notary.pem",
"../fixtures/notary.key",
"../fixtures/notary-server.pem",
"../fixtures/notary-server.key",
signed.NewEd25519(),
"",
nil,

View File

@ -9,7 +9,7 @@ import (
func TestAddCert(t *testing.T) {
// Read certificate from file
b, err := ioutil.ReadFile("../fixtures/notary/root-ca.crt")
b, err := ioutil.ReadFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
@ -42,7 +42,7 @@ func TestAddCert(t *testing.T) {
func TestAddCertFromFile(t *testing.T) {
store := NewX509MemStore()
err := store.AddCertFromFile("../fixtures/notary/root-ca.crt")
err := store.AddCertFromFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("failed to load certificate from file: %v", err)
}
@ -53,7 +53,7 @@ func TestAddCertFromFile(t *testing.T) {
}
func TestAddCertFromPEM(t *testing.T) {
b, err := ioutil.ReadFile("../fixtures/notary/root-ca.crt")
b, err := ioutil.ReadFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
@ -70,7 +70,7 @@ func TestAddCertFromPEM(t *testing.T) {
}
func TestRemoveCert(t *testing.T) {
b, err := ioutil.ReadFile("../fixtures/notary/root-ca.crt")
b, err := ioutil.ReadFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
@ -108,7 +108,7 @@ func TestRemoveCert(t *testing.T) {
func TestInexistentGetCertificateByKeyID(t *testing.T) {
store := NewX509MemStore()
err := store.AddCertFromFile("../fixtures/notary/root-ca.crt")
err := store.AddCertFromFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("failed to load certificate from file: %v", err)
}
@ -120,7 +120,7 @@ func TestInexistentGetCertificateByKeyID(t *testing.T) {
}
func TestGetCertificateByKeyID(t *testing.T) {
b, err := ioutil.ReadFile("../fixtures/notary/root-ca.crt")
b, err := ioutil.ReadFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
@ -155,7 +155,7 @@ func TestGetVerifyOpsErrorsWithoutCerts(t *testing.T) {
store := NewX509MemStore()
// Try to get VerifyOptions without certs added
_, err := store.GetVerifyOptions("docker.com")
_, err := store.GetVerifyOptions("example.com")
if err == nil {
t.Fatalf("expecting an error when getting empty VerifyOptions")
}
@ -164,16 +164,16 @@ func TestGetVerifyOpsErrorsWithoutCerts(t *testing.T) {
func TestVerifyLeafCertFromIntermediate(t *testing.T) {
// Create a store and add a root
store := NewX509MemStore()
err := store.AddCertFromFile("../fixtures/notary/ca.crt")
err := store.AddCertFromFile("../fixtures/intermediate-ca.crt")
if err != nil {
t.Fatalf("failed to load certificate from file: %v", err)
}
// Get the VerifyOptions from our Store
opts, err := store.GetVerifyOptions("secure.docker.com")
opts, err := store.GetVerifyOptions("secure.example.com")
// Get leaf certificate
b, err := ioutil.ReadFile("../fixtures/notary/secure.docker.com.crt")
b, err := ioutil.ReadFile("../fixtures/secure.example.com.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
@ -195,16 +195,16 @@ func TestVerifyLeafCertFromIntermediate(t *testing.T) {
func TestVerifyIntermediateFromRoot(t *testing.T) {
// Create a store and add a root
store := NewX509MemStore()
err := store.AddCertFromFile("../fixtures/notary/root-ca.crt")
err := store.AddCertFromFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("failed to load certificate from file: %v", err)
}
// Get the VerifyOptions from our Store
opts, err := store.GetVerifyOptions("Docker CA")
opts, err := store.GetVerifyOptions("Notary Testing CA")
// Get leaf certificate
b, err := ioutil.ReadFile("../fixtures/notary/ca.crt")
b, err := ioutil.ReadFile("../fixtures/intermediate-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
@ -229,7 +229,7 @@ func TestNewX509FilteredMemStore(t *testing.T) {
})
// AddCert should succeed because this is a CA being added
err := store.AddCertFromFile("../fixtures/notary/root-ca.crt")
err := store.AddCertFromFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("failed to load certificate from file: %v", err)
}
@ -239,7 +239,7 @@ func TestNewX509FilteredMemStore(t *testing.T) {
}
// AddCert should fail because this is a leaf cert being added
err = store.AddCertFromFile("../fixtures/notary/secure.docker.com.crt")
err = store.AddCertFromFile("../fixtures/secure.example.com.crt")
if err == nil {
t.Fatalf("was expecting non-CA certificate to be rejected")
}
@ -248,7 +248,7 @@ func TestNewX509FilteredMemStore(t *testing.T) {
func TestGetCertificatePool(t *testing.T) {
// Create a store and add a root
store := NewX509MemStore()
err := store.AddCertFromFile("../fixtures/notary/root-ca.crt")
err := store.AddCertFromFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("failed to load certificate from file: %v", err)
}

View File

@ -7,19 +7,19 @@ import (
func TestVerifyLeafSuccessfully(t *testing.T) {
// Get root certificate
rootCA, err := LoadCertFromFile("../fixtures/notary/root-ca.crt")
rootCA, err := LoadCertFromFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
// Get intermediate certificate
intermediateCA, err := LoadCertFromFile("../fixtures/notary/ca.crt")
intermediateCA, err := LoadCertFromFile("../fixtures/intermediate-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
// Get leaf certificate
leafCert, err := LoadCertFromFile("../fixtures/notary/secure.docker.com.crt")
leafCert, err := LoadCertFromFile("../fixtures/secure.example.com.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
@ -35,7 +35,7 @@ func TestVerifyLeafSuccessfully(t *testing.T) {
certList := []*x509.Certificate{leafCert, intermediateCA}
// Try to find a valid chain for cert
err = Verify(store, "secure.docker.com", certList)
err = Verify(store, "secure.example.com", certList)
if err != nil {
t.Fatalf("expected to find a valid chain for this certificate: %v", err)
}
@ -43,19 +43,19 @@ func TestVerifyLeafSuccessfully(t *testing.T) {
func TestVerifyLeafSuccessfullyWithMultipleIntermediates(t *testing.T) {
// Get root certificate
rootCA, err := LoadCertFromFile("../fixtures/notary/root-ca.crt")
rootCA, err := LoadCertFromFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
// Get intermediate certificate
intermediateCA, err := LoadCertFromFile("../fixtures/notary/ca.crt")
intermediateCA, err := LoadCertFromFile("../fixtures/intermediate-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
// Get leaf certificate
leafCert, err := LoadCertFromFile("../fixtures/notary/secure.docker.com.crt")
leafCert, err := LoadCertFromFile("../fixtures/secure.example.com.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
@ -71,7 +71,7 @@ func TestVerifyLeafSuccessfullyWithMultipleIntermediates(t *testing.T) {
certList := []*x509.Certificate{leafCert, intermediateCA, intermediateCA, rootCA}
// Try to find a valid chain for cert
err = Verify(store, "secure.docker.com", certList)
err = Verify(store, "secure.example.com", certList)
if err != nil {
t.Fatalf("expected to find a valid chain for this certificate: %v", err)
}
@ -79,13 +79,13 @@ func TestVerifyLeafSuccessfullyWithMultipleIntermediates(t *testing.T) {
func TestVerifyLeafWithNoIntermediate(t *testing.T) {
// Get root certificate
rootCA, err := LoadCertFromFile("../fixtures/notary/root-ca.crt")
rootCA, err := LoadCertFromFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
// Get leaf certificate
leafCert, err := LoadCertFromFile("../fixtures/notary/secure.docker.com.crt")
leafCert, err := LoadCertFromFile("../fixtures/secure.example.com.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
@ -101,7 +101,7 @@ func TestVerifyLeafWithNoIntermediate(t *testing.T) {
certList := []*x509.Certificate{leafCert, leafCert}
// Try to find a valid chain for cert
err = Verify(store, "secure.docker.com", certList)
err = Verify(store, "secure.example.com", certList)
if err == nil {
t.Fatalf("expected error due to more than one leaf certificate")
}
@ -109,13 +109,13 @@ func TestVerifyLeafWithNoIntermediate(t *testing.T) {
func TestVerifyLeafWithNoLeaf(t *testing.T) {
// Get root certificate
rootCA, err := LoadCertFromFile("../fixtures/notary/root-ca.crt")
rootCA, err := LoadCertFromFile("../fixtures/root-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
// Get intermediate certificate
intermediateCA, err := LoadCertFromFile("../fixtures/notary/ca.crt")
intermediateCA, err := LoadCertFromFile("../fixtures/intermediate-ca.crt")
if err != nil {
t.Fatalf("couldn't load fixture: %v", err)
}
@ -131,7 +131,7 @@ func TestVerifyLeafWithNoLeaf(t *testing.T) {
certList := []*x509.Certificate{intermediateCA, intermediateCA}
// Try to find a valid chain for cert
err = Verify(store, "secure.docker.com", certList)
err = Verify(store, "secure.example.com", certList)
if err == nil {
t.Fatalf("expected error due to no leafs provided")
}