Skip to content

Commit e39b435

Browse files
committed
Fix push agent installation in containers
1 parent ea7019a commit e39b435

File tree

3 files changed

+43
-31
lines changed

3 files changed

+43
-31
lines changed

Library/test-helpers/lime_con_install_upstream.sh

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,16 @@ RPMPKG=$( awk '/Wrote:/ { print $2 }' build.log )
9292
rpm -ivh $RPMPKG
9393

9494
# enable rust agent COPR repo and install agent
95-
cat > /etc/yum.repos.d/copr-rust-keylime-master.repo <<_EOF
96-
[copr-rust-keylime-master]
97-
name=Copr repo for keylime-rust-keylime-master owned by packit
98-
baseurl=https://download.copr.fedorainfracloud.org/results/packit/keylime-rust-keylime-master/fedora-\$releasever-\$basearch/
99-
type=rpm-md
100-
skip_if_unavailable=True
101-
gpgcheck=1
102-
gpgkey=https://download.copr.fedorainfracloud.org/results/packit/keylime-rust-keylime-master/pubkey.gpg
103-
repo_gpgcheck=0
104-
enabled=1
105-
enabled_metadata=1
106-
priority=1
107-
_EOF
108-
sed -i 's|keylime-rust-keylime-master/fedora|keylime-rust-keylime-master/centos-stream|' /etc/yum.repos.d/copr-rust-keylime-master.repo
109-
yum -y install keylime-agent-rust
95+
if [ -f /etc/fedora-release ]; then
96+
dnf -y copr enable packit/keylime-rust-keylime-master-fedora
97+
else
98+
_MAJOR=$( rpm -q --qf '%{VERSION}' centos-stream-release | cut -d '.' -f 1 )
99+
_ARCH=$( arch )
100+
dnf -y copr enable packit/keylime-rust-keylime-master-centos centos-stream-${_MAJOR}-${_ARCH}
101+
fi
102+
yum -y install keylime-agent-rust keylime-agent-rust-push
110103
curl -o /etc/keylime/keylime-agent.conf https://raw.githubusercontent.com/keylime/rust-keylime/master/keylime-agent.conf
111-
mkdir -p /etc/systemd/system/keylime_agent.service.d
104+
mkdir -p /etc/systemd/system/keylime_agent.service.d /etc/systemd/system/keylime_push_model_agent.service.d
112105
mkdir -p /etc/keylime/agent.conf.d
113106

114107
# fix conf file ownership

container/functional/keylime_agent_container-basic-attestation/main.fmf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require:
2121
- podman
2222
recommend:
2323
- keylime
24-
duration: 10m
24+
duration: 15m
2525
enabled: true
2626
adjust:
2727
- when: swtpm != yes

container/functional/keylime_agent_container-basic-attestation/test.sh

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ rlJournalStart
5050
rlRun "limeUpdateConf verifier challenge_lifetime 1800"
5151
rlRun "limeUpdateConf agent attestation_interval_seconds 10"
5252
rlRun "limeUpdateConf agent tls_accept_invalid_hostnames true"
53+
rlRun "limeUpdateConf agent verifier_url '\"https://$SERVER_IP:8881\"'"
5354
fi
5455

5556
# start tpm emulator
@@ -121,41 +122,59 @@ rlJournalStart
121122

122123
rlPhaseStartTest "Add keylime agents"
123124
rlRun -s "keylime_tenant -v $SERVER_IP -t $IP_AGENT_FIRST -u $AGENT_ID_FIRST --runtime-policy policy1.json -f /etc/hosts -c add ${TENANT_ARGS}"
124-
rlRun "limeWaitForAgentStatus $AGENT_ID_FIRST 'Get Quote'"
125+
if [ "${AGENT_SERVICE}" == "PushAgent" ]; then
126+
rlRun "limeWaitForAgentStatus --field attestation_status $AGENT_ID_FIRST 'PASS'"
127+
else
128+
rlRun "limeWaitForAgentStatus $AGENT_ID_FIRST 'Get Quote'"
129+
fi
125130
rlRun -s "keylime_tenant -c cvlist"
126131
rlAssertGrep "{'code': 200, 'status': 'Success', 'results': {'uuids':.*'$AGENT_ID_FIRST'" $rlRun_LOG -E
127132
#check second agent
128133
rlRun -s "keylime_tenant -v $SERVER_IP -t $IP_AGENT_SECOND -u $AGENT_ID_SECOND --runtime-policy policy2.json -f /etc/hosts -c add ${TENANT_ARGS}"
129-
rlRun "limeWaitForAgentStatus $AGENT_ID_SECOND 'Get Quote'"
134+
if [ "${AGENT_SERVICE}" == "PushAgent" ]; then
135+
rlRun "limeWaitForAgentStatus --field attestation_status $AGENT_ID_SECOND 'PASS'"
136+
else
137+
rlRun "limeWaitForAgentStatus $AGENT_ID_SECOND 'Get Quote'"
138+
fi
130139
rlPhaseEnd
131140

132141
rlPhaseStartTest "Execute good scripts"
133142
rlRun "$TESTDIR_FIRST/good-script.sh"
134143
rlRun "$TESTDIR_SECOND/good-script.sh"
135-
sleep 5
136-
rlRun "limeWaitForAgentStatus $AGENT_ID_FIRST 'Get Quote'"
137-
rlRun "limeWaitForAgentStatus $AGENT_ID_SECOND 'Get Quote'"
144+
sleep $limeTimeout
145+
if [ "${AGENT_SERVICE}" == "PushAgent" ]; then
146+
rlRun "limeWaitForAgentStatus --field attestation_status $AGENT_ID_FIRST 'PASS'"
147+
rlRun "limeWaitForAgentStatus --field attestation_status $AGENT_ID_SECOND 'PASS'"
148+
else
149+
rlRun "limeWaitForAgentStatus $AGENT_ID_FIRST 'Get Quote'"
150+
rlRun "limeWaitForAgentStatus $AGENT_ID_SECOND 'Get Quote'"
151+
fi
138152
rlPhaseEnd
139153

140-
141154
rlPhaseStartTest "Fail first keylime agent and check second"
142155
rlRun "echo -e '#!/bin/bash\necho boom' > $TESTDIR_FIRST/bad-script.sh && chmod a+x $TESTDIR_FIRST/bad-script.sh"
143156
rlRun "$TESTDIR_FIRST/bad-script.sh"
144-
rlRun "rlWaitForCmd 'tail -30 \$(limeVerifierLogfile) | grep -q \"Agent $AGENT_ID_FIRST failed\"' -m 30 -d 2 -t 60"
145-
rlRun "limeWaitForAgentStatus $AGENT_ID_FIRST '(Failed|Invalid Quote)'"
157+
rlRun "rlWaitForCmd 'tail -30 \$(limeVerifierLogfile) | grep -Eiq \"Agent.*$AGENT_ID_FIRST.*failed\"' -m 30 -d 2 -t 60"
146158
rlAssertGrep "WARNING - File not found in allowlist: $TESTDIR_FIRST/bad-script.sh" $(limeVerifierLogfile)
147-
rlAssertGrep "WARNING - Agent $AGENT_ID_FIRST failed, stopping polling" $(limeVerifierLogfile)
148-
#check status of first agent
149-
rlRun "limeWaitForAgentStatus $AGENT_ID_SECOND 'Get Quote'"
159+
if [ "${AGENT_SERVICE}" == "PushAgent" ]; then
160+
rlRun "limeWaitForAgentStatus --field attestation_status $AGENT_ID_FIRST 'FAIL'"
161+
rlRun "limeWaitForAgentStatus --field attestation_status $AGENT_ID_SECOND 'PASS'"
162+
else
163+
rlRun "limeWaitForAgentStatus $AGENT_ID_FIRST '(Failed|Invalid Quote)'"
164+
rlRun "limeWaitForAgentStatus $AGENT_ID_SECOND 'Get Quote'"
165+
fi
150166
rlPhaseEnd
151167

152168
rlPhaseStartTest "Fail second keylime agent"
153169
rlRun "echo -e '#!/bin/bash\necho boom' > $TESTDIR_SECOND/bad-script.sh && chmod a+x $TESTDIR_SECOND/bad-script.sh"
154170
rlRun "$TESTDIR_SECOND/bad-script.sh"
155-
rlRun "rlWaitForCmd 'tail -30 \$(limeVerifierLogfile) | grep -q \"Agent $AGENT_ID_SECOND failed\"' -m 30 -d 2 -t 60"
156-
rlRun "limeWaitForAgentStatus $AGENT_ID_SECOND '(Failed|Invalid Quote)'"
171+
rlRun "rlWaitForCmd 'tail -30 \$(limeVerifierLogfile) | grep -Eiq \"Agent.*$AGENT_ID_SECOND.*failed\"' -m 30 -d 2 -t 60"
157172
rlAssertGrep "WARNING - File not found in allowlist: $TESTDIR_SECOND/bad-script.sh" $(limeVerifierLogfile)
158-
rlAssertGrep "WARNING - Agent $AGENT_ID_SECOND failed, stopping polling" $(limeVerifierLogfile)
173+
if [ "${AGENT_SERVICE}" == "PushAgent" ]; then
174+
rlRun "limeWaitForAgentStatus --field attestation_status $AGENT_ID_SECOND 'FAIL'"
175+
else
176+
rlRun "limeWaitForAgentStatus $AGENT_ID_SECOND '(Failed|Invalid Quote)'"
177+
fi
159178
rlPhaseEnd
160179

161180
rlPhaseStartCleanup "Do the keylime cleanup"

0 commit comments

Comments
 (0)