Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Fix test using hardcoded credentials for defunct server.
Browse files Browse the repository at this point in the history
Now it just uses credentials provided by the user to CMake.

Signed-off-by: Patrick Vacek <[email protected]>
  • Loading branch information
pattivacek committed Jan 10, 2019
1 parent 9ca6198 commit a22ce5c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
16 changes: 9 additions & 7 deletions src/sota_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,6 @@ if (BUILD_SOTA_TOOLS)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
set_tests_properties(garage-deploy-online-signing PROPERTIES PASS_REGULAR_EXPRESSION "Online signing with garage-deploy is currently unsupported")

# Use garage-sign to offline sign targets for destination repository.
# Remove local tuf repo generated by garage-sign after use.
add_test(NAME garage-deploy-offline-signing
COMMAND ${PROJECT_SOURCE_DIR}/tests/sota_tools/test-garage-deploy-offline-signing $<TARGET_FILE:garage-deploy>
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
set_tests_properties(garage-deploy-offline-signing PROPERTIES PASS_REGULAR_EXPRESSION "Success")

# Abort if destination server is unavailable.
add_test(NAME garage-deploy-upload-failed
COMMAND ${PROJECT_SOURCE_DIR}/tests/sota_tools/test-garage-deploy-upload-failed $<TARGET_FILE:garage-deploy>
Expand All @@ -323,6 +316,15 @@ if (BUILD_SOTA_TOOLS)
COMMAND ${PROJECT_SOURCE_DIR}/tests/sota_tools/test-garage-deploy-missing-push-credentials $<TARGET_FILE:garage-deploy>
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

if(SOTA_PACKED_CREDENTIALS)
# Use garage-sign to offline sign targets for destination repository.
# Remove local tuf repo generated by garage-sign after use.
add_test(NAME garage-deploy-offline-signing
COMMAND ${PROJECT_SOURCE_DIR}/tests/sota_tools/test-garage-deploy-offline-signing $<TARGET_FILE:garage-deploy>
${SOTA_PACKED_CREDENTIALS} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
set_tests_properties(garage-deploy-offline-signing PROPERTIES PASS_REGULAR_EXPRESSION "Success" LABELS "credentials")
endif(SOTA_PACKED_CREDENTIALS)

endif (BUILD_SOTA_TOOLS)

aktualizr_source_file_checks(${GARAGE_PUSH_SRCS} ${GARAGE_CHECK_SRCS} ${GARAGE_DEPLOY_SRCS} ${SOTA_TOOLS_LIB_SRC} ${ALL_SOTA_TOOLS_HEADERS} ${TEST_SOURCES})
Expand Down
2 changes: 2 additions & 0 deletions src/sota_tools/authenticate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ TEST(authenticate, invalid_file) {

/* Check if credentials support offline signing. */
TEST(authenticate, offline_sign_creds) {
// Note that these credentials point to the old CI infrastructure that is now
// defunct. However, for the sake of this test, that doesn't matter.
boost::filesystem::path auth_offline = "tests/sota_tools/auth_test_good_offline.zip";
ServerCredentials creds_offline(auth_offline);
EXPECT_TRUE(creds_offline.CanSignOffline());
Expand Down
18 changes: 10 additions & 8 deletions tests/sota_tools/test-garage-deploy-offline-signing
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ TREEHUB="{\
}\
}"

echo "#!/bin/bash" > $TEMP_DIR/garage-sign
echo "mkdir -p ./tuf/aktualizr" >> $TEMP_DIR/garage-sign
chmod +x $TEMP_DIR/garage-sign
echo "#!/bin/bash" > "$TEMP_DIR/garage-sign"
echo "mkdir -p ./tuf/aktualizr" >> "$TEMP_DIR/garage-sign"
chmod +x "$TEMP_DIR/garage-sign"
export PATH=$PATH:$TEMP_DIR

echo $TREEHUB > $TEMP_DIR/treehub.json
./tests/sota_tools/treehub_server.py $PORT &
PUSH_CREDS="$(pwd)/tests/sota_tools/auth_test_good_offline.zip"
echo "$TREEHUB" > "$TEMP_DIR/treehub.json"
./tests/sota_tools/treehub_server.py "$PORT" &
sleep 1
cd $TEMP_DIR
$1 --commit 16ef2f2629dc9263fdf3c0f032563a2d757623bbc11cf99df25c3c3f258dccbe -f $TEMP_DIR/treehub.json -p $PUSH_CREDS --name testname -h hwids
cd "$TEMP_DIR"
# Currently, if credentials do not support offline signing, this will fail. If
# that ever changes, this will need to verify that the credentials do support
# offline signing.
$1 --commit 16ef2f2629dc9263fdf3c0f032563a2d757623bbc11cf99df25c3c3f258dccbe -f "$TEMP_DIR/treehub.json" -p "$2" --name testname -h hwids
exit_code=$?
if [ -d "./tuf/aktualizr" ]; then
echo "garage-sign tuf repo still present!"
Expand Down

0 comments on commit a22ce5c

Please sign in to comment.