You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2016/03/08 22:28:31 UTC
svn commit: r1734164 - in /qpid/trunk/qpid/cpp/src/tests: qpid-send.cpp
ssl_test
Author: gsim
Date: Tue Mar 8 21:28:30 2016
New Revision: 1734164
URL: http://svn.apache.org/viewvc?rev=1734164&view=rev
Log:
QPID-7130: added test for retrieving authenticated username when using ssl
Modified:
qpid/trunk/qpid/cpp/src/tests/qpid-send.cpp
qpid/trunk/qpid/cpp/src/tests/ssl_test
Modified: qpid/trunk/qpid/cpp/src/tests/qpid-send.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/qpid-send.cpp?rev=1734164&r1=1734163&r2=1734164&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/qpid-send.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/qpid-send.cpp Tue Mar 8 21:28:30 2016
@@ -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);
Modified: qpid/trunk/qpid/cpp/src/tests/ssl_test
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/ssl_test?rev=1734164&r1=1734163&r2=1734164&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/ssl_test (original)
+++ qpid/trunk/qpid/cpp/src/tests/ssl_test Tue Mar 8 21:28:30 2016
@@ -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
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org