diff options
author | Gordon Sim <gsim@apache.org> | 2016-03-08 21:28:30 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2016-03-08 21:28:30 +0000 |
commit | e7deaaa742c880fb5bd78f62c2cebc9b43bf4019 (patch) | |
tree | 7b89767792edabc0757799bc7991fbe772813dae | |
parent | 92e6d3147fb77dc9a16db666a7716d3446b5a8f9 (diff) | |
download | qpid-python-e7deaaa742c880fb5bd78f62c2cebc9b43bf4019.tar.gz |
QPID-7130: added test for retrieving authenticated username when using ssl
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1734164 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/tests/qpid-send.cpp | 4 | ||||
-rwxr-xr-x | qpid/cpp/src/tests/ssl_test | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/qpid/cpp/src/tests/qpid-send.cpp b/qpid/cpp/src/tests/qpid-send.cpp index bc0ad78601..1f4e25e5c1 100644 --- a/qpid/cpp/src/tests/qpid-send.cpp +++ b/qpid/cpp/src/tests/qpid-send.cpp @@ -70,6 +70,7 @@ struct Options : public qpid::Options uint ttl; uint priority; std::string userid; + bool autouserid; std::string correlationid; string_vector properties; string_vector entries; @@ -102,6 +103,7 @@ struct Options : public qpid::Options durable(false), ttl(0), priority(0), + autouserid(false), contentString(), contentSize(0), contentStdin(false), @@ -135,6 +137,7 @@ struct Options : public qpid::Options ("property,P", qpid::optValue(properties, "NAME=VALUE"), "specify message property") ("correlation-id", qpid::optValue(correlationid, "ID"), "correlation-id for message") ("user-id", qpid::optValue(userid, "USERID"), "userid for message") + ("auto-user-id", qpid::optValue(autouserid, "yes| no"), "set userid for message based on authenticated identity") ("content-string", qpid::optValue(contentString, "CONTENT"), "use CONTENT as message content") ("content-size", qpid::optValue(contentSize, "N"), "create an N-byte message content") ("content-map,M", qpid::optValue(entries, "NAME=VALUE"), "specify entry for map content") @@ -378,6 +381,7 @@ int main(int argc, char ** argv) msg.setReplyTo(Address(opts.replyto)); } if (!opts.userid.empty()) msg.setUserId(opts.userid); + else if (opts.autouserid) msg.setUserId(connection.getAuthenticatedUsername()); if (!opts.id.empty()) msg.setMessageId(opts.id); if (!opts.correlationid.empty()) msg.setCorrelationId(opts.correlationid); opts.setProperties(msg); diff --git a/qpid/cpp/src/tests/ssl_test b/qpid/cpp/src/tests/ssl_test index d681059495..46068afefb 100755 --- a/qpid/cpp/src/tests/ssl_test +++ b/qpid/cpp/src/tests/ssl_test @@ -222,11 +222,17 @@ URL=amqp:ssl:$TEST_HOSTNAME:$PORT2 MSG2=`./qpid-receive -b $URL --connection-options "{ssl-cert-name: $TEST_CLIENT_CERT }" -a "bar;{create:always}" --messages 1` test "$MSG2" = "hello" || { echo "receive failed '$MSG2' != 'hello'"; exit 1; } + ## Make sure that connect fails with an invalid SSL cert-name ./qpid-send -b $URL --connection-options "{ssl-cert-name: pignose }" --content-string=hello -a "baz;{create:always}" 2>/dev/null 1>/dev/null MSG3=`./qpid-receive -b $URL --connection-options "{ssl-cert-name: pignose }" -a "baz;{create:always}" --messages 1 2>/dev/null` test "$MSG3" = "" || { echo "receive succeeded without valid ssl cert '$MSG3' != ''"; exit 1; } +## Set the userid in the message to the authenticated username +./qpid-send -b $URL --connection-options "{ssl-cert-name: $TEST_CLIENT_CERT }" --auto-user-id true --content-string=hello -a "bar;{create:always}" +RECEIVED_USER=`./qpid-receive -b $URL --connection-options "{ssl-cert-name: $TEST_CLIENT_CERT }" -a "bar;{create:always}" --messages 1 --print-headers true | awk '/UserId/{print $2}'` +test "$RECEIVED_USER" = $TEST_CLIENT_CERT || { echo "user id not as expected: $RECEIVED_USER"; exit 1; } + stop_brokers # Test ssl muxed with plain TCP on the same connection |