Skip to content

Commit

Permalink
add identity search component to e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: linus-sun <[email protected]>
  • Loading branch information
linus-sun committed Nov 21, 2024
1 parent b281a00 commit f26c07f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ jobs:
e2e-tests:
name: Run end-to-end tests
runs-on: ubuntu-latest
services:
db:
image: mariadb
env:
DATABASE_HOST: 127.0.0.1
MYSQL_ROOT_PASSWORD: zaphod
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: zaphod
ports:
- 3306:3306
options: --health-cmd="mysql --user=$$MYSQL_USER --password=$$MYSQL_PASSWORD --silent --execute "SHOW DATABASES;" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand All @@ -90,4 +102,6 @@ jobs:
check-latest: true
- name: run Rekor end-to-end test
run: ./pkg/test/rekor_e2e/rekor_monitor_e2e_test.sh
- name: run CT end-to-end test
run: ./pkg/test/ct_e2e/ct_monitor_e2e_test.sh

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
ctclient "github.com/google/certificate-transparency-go/client"
"github.com/google/certificate-transparency-go/jsonclient"
"github.com/sigstore/rekor-monitor/pkg/ct"
"github.com/sigstore/rekor-monitor/pkg/identity"
)

const (
Expand All @@ -37,7 +38,7 @@ const (
)

func TestCTConsistencyCheck(t *testing.T) {
fulcioClient, err := ctclient.New("http://localhost:8080/testlog", http.DefaultClient, jsonclient.Options{})
fulcioClient, err := ctclient.New("http://127.0.0.1:8080/testlog", http.DefaultClient, jsonclient.Options{})
if err != nil {
t.Errorf("error instantiating ct client: %v", err)
}
Expand All @@ -50,8 +51,20 @@ func TestCTConsistencyCheck(t *testing.T) {
tempLogInfoFileName := tempLogInfoFile.Name()
defer os.Remove(tempLogInfoFileName)

err = ct.RunConsistencyCheck(fulcioClient, tempLogInfoFileName)
_, _, err = ct.RunConsistencyCheck(fulcioClient, tempLogInfoFileName)
if err != nil {
t.Errorf("failed to successfully complete consistency check: %v", err)
}

_, err = ct.IdentitySearch(fulcioClient, 0, 1, identity.MonitoredValues{
CertificateIdentities: []identity.CertificateIdentity{
{
CertSubject: "test-cert-subject",
Issuers: []string{},
},
},
})
if err != nil {
t.Errorf("failed to successfully complete identity search: %v", err)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,56 +21,38 @@ pushd $HOME
echo "downloading service repos"
for repo in certificate-transparency-go trillian; do
if [[ ! -d $repo ]]; then
git clone https://github.com/sigstore/${repo}.git
git clone https://github.com/google/${repo}.git
fi
done

docker_compose="docker compose"

pushd ./certificate-transparency-go/trillian/examples/deployment/docker/ctfe/
docker compose up -d
until [ $(${docker_compose} ps | grep -c "(healthy)") == 1 ];
do
if [ $count -eq 6 ]; then
echo "! timeout reached"
exit 1
else
echo -n "."
sleep 5
let 'count+=1'
fi
done
sleep 30
popd

docker exec -i ctfe-db mariadb -pzaphod -Dtest < ./trillian/storage/mysql/schema/storage.sql
docker exec -i ctfe-db mariadb -pzaphod -Dtest < ./certificate-transparency-go/trillian/ctfe/storage/mysql/schema.sql

CTFE_CONF_DIR=/tmp/ctfedocker
if [ -d $CTFE_CONF_DIR ]; then
if [ ! -d $CTFE_CONF_DIR ]; then
mkdir ${CTFE_CONF_DIR}
fi

TREE_ID=$(go run github.com/google/trillian/cmd/createtree@master --admin_server=localhost:8090)
TREE_ID=$(go run github.com/google/trillian/cmd/createtree@master --admin_server=127.0.0.1:8090)
sed "s/@TREE_ID@/${TREE_ID}/" ./certificate-transparency-go/trillian/examples/deployment/docker/ctfe/ct_server.cfg > ${CTFE_CONF_DIR}/ct_server.cfg
cp ./certificate-transparency-go/trillian/testdata/fake-ca.cert ${CTFE_CONF_DIR}
docker volume create --driver local --opt type=none --opt device=${CTFE_CONF_DIR} --opt o=bind ctfe_config

pushd ./certificate-transparency-go/trillian/examples/deployment/docker/ctfe/
docker compose down
docker compose --profile frontend up -d
until [ $(${docker_compose} ps | grep -c "(healthy)") == 1 ];
do
if [ $count -eq 6 ]; then
echo "! timeout reached"
exit 1
else
echo -n "."
sleep 5
let 'count+=1'
fi
done
sleep 30
popd

docker ps

popd
go test -tags=ct_e2e -v -race ./pkg/test/ct_e2e/...

Expand Down

0 comments on commit f26c07f

Please sign in to comment.