Skip to content

Commit 5afb533

Browse files
Merge pull request #176 from danielskinstad/auth-token
MEN-8591
2 parents fd083d3 + 7bcd1b7 commit 5afb533

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/mender-inventory-mender-configure

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,26 @@ if ! [ -f "$CONFIG" ]; then
3030
fi
3131

3232
# Fetch Authentication token and server from Mender Auth Manager.
33-
DBUS_REPLY="$(dbus-send \
34-
--system \
35-
--print-reply \
36-
--dest=io.mender.AuthenticationManager \
37-
/io/mender/AuthenticationManager \
38-
io.mender.Authentication1.GetJwtToken \
39-
| sed -ne '/^ *string ".*" *$/ {s/^ *string "\(.*\)" *$/\1/; p}')"
33+
DBUS_RAW=$(dbus-send \
34+
--system \
35+
--print-reply \
36+
--dest=io.mender.AuthenticationManager \
37+
/io/mender/AuthenticationManager \
38+
io.mender.Authentication1.GetJwtToken)
39+
40+
DBUS_REPLY=$(echo "$DBUS_RAW" | sed -ne '/^ *string ".*" *$/ {s/^ *string "\(.*\)" *$/\1/; p}')
4041

4142
AUTH_TOKEN="$(echo "$DBUS_REPLY" | sed -ne '1p')"
4243
SERVER="$(echo "$DBUS_REPLY" | sed -ne '2p')"
4344

4445
if [ -z "$AUTH_TOKEN" ]; then
45-
echo "An authentication token could not be obtained over DBus."
46-
exit 1
46+
echo "mender-inventory-mender-configure: An authentication token could not be obtained over DBus."
47+
# Don't produce an error. Most likely mender-auth is not ready or
48+
# the device hasn't been accepted
49+
exit 0
4750
fi
4851
if [ -z "$SERVER" ]; then
49-
echo "A server address could not be obtained over DBus."
52+
echo "mender-inventory-mender-configure: A server address could not be obtained over DBus."
5053
exit 1
5154
fi
5255

tests/unit/test_inventory.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ testInvalidEndpoint() {
7676
testMissingJwtToken() {
7777
export TEST_AUTH_TOKEN_EMPTY=1
7878
output="$("${inv_script}")"
79-
assertNotEquals 0 $?
79+
assertEquals 0 $?
8080
assertEquals "" "${output}"
8181
assertEquals "" "$(cat "$TEST_HTTP_LOG" 2>/dev/null)"
8282
}

0 commit comments

Comments
 (0)