You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2012/07/16 16:09:41 UTC

svn commit: r1362043 - in /qpid/proton/trunk: proton-c/bindings/python/python.i proton-c/src/sasl/sasl.c tests/proton_tests/__init__.py tests/proton_tests/sasl.py

Author: rhs
Date: Mon Jul 16 14:09:41 2012
New Revision: 1362043

URL: http://svn.apache.org/viewvc?rev=1362043&view=rev
Log:
fixed bug in sasl layer; added tests

Added:
    qpid/proton/trunk/tests/proton_tests/sasl.py
Modified:
    qpid/proton/trunk/proton-c/bindings/python/python.i
    qpid/proton/trunk/proton-c/src/sasl/sasl.c
    qpid/proton/trunk/tests/proton_tests/__init__.py

Modified: qpid/proton/trunk/proton-c/bindings/python/python.i
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/python.i?rev=1362043&r1=1362042&r2=1362043&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/python/python.i (original)
+++ qpid/proton/trunk/proton-c/bindings/python/python.i Mon Jul 16 14:09:41 2012
@@ -104,6 +104,23 @@ ssize_t pn_input(pn_transport_t *transpo
 %}
 %ignore pn_output;
 
+ssize_t pn_sasl_input(pn_sasl_t *sasl, char *STRING, size_t LENGTH);
+%ignore pn_sasl_input;
+
+%rename(pn_sasl_output) wrap_pn_sasl_output;
+%inline %{
+  int wrap_pn_sasl_output(pn_sasl_t *sasl, char *OUTPUT, size_t *OUTPUT_SIZE) {
+    ssize_t sz = pn_sasl_output(sasl, OUTPUT, *OUTPUT_SIZE);
+    if (sz >= 0) {
+      *OUTPUT_SIZE = sz;
+    } else {
+      *OUTPUT_SIZE = 0;
+    }
+    return sz;
+  }
+%}
+%ignore pn_sasl_output;
+
 %rename(pn_delivery) wrap_pn_delivery;
 %inline %{
   pn_delivery_t *wrap_pn_delivery(pn_link_t *link, char *STRING, size_t LENGTH) {

Modified: qpid/proton/trunk/proton-c/src/sasl/sasl.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/sasl/sasl.c?rev=1362043&r1=1362042&r2=1362043&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/sasl/sasl.c (original)
+++ qpid/proton/trunk/proton-c/src/sasl/sasl.c Mon Jul 16 14:09:41 2012
@@ -57,7 +57,6 @@ pn_sasl_t *pn_sasl()
 {
   pn_sasl_t *sasl = malloc(sizeof(pn_sasl_t));
   sasl->disp = pn_dispatcher(1, sasl);
-  sasl->disp->batch = false;
 
   pn_dispatcher_action(sasl->disp, SASL_INIT, "SASL-INIT", pn_do_init);
   pn_dispatcher_action(sasl->disp, SASL_MECHANISMS, "SASL-MECHANISMS", pn_do_mechanisms);
@@ -272,6 +271,13 @@ void pn_sasl_process(pn_sasl_t *sasl)
   if (!sasl->client && sasl->outcome != PN_SASL_NONE && !sasl->sent_done) {
     pn_server_done(sasl);
     sasl->sent_done = true;
+  }
+
+  // XXX: need to finish this check when challenge/response is complete
+  //      check for client is outome is received
+  //      check for server is that there are no pending frames (either init
+  //      or challenges) from client
+  if (!sasl->client && sasl->sent_done && sasl->rcvd_init) {
     sasl->rcvd_done = true;
     sasl->disp->halt = true;
   }
@@ -282,6 +288,8 @@ ssize_t pn_sasl_input(pn_sasl_t *sasl, c
   ssize_t n = pn_dispatcher_input(sasl->disp, bytes, available);
   if (n < 0) return n;
 
+  pn_sasl_process(sasl);
+
   if (sasl->rcvd_done) {
     if (pn_sasl_state(sasl) == PN_SASL_PASS) {
       if (n) {

Modified: qpid/proton/trunk/tests/proton_tests/__init__.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/proton_tests/__init__.py?rev=1362043&r1=1362042&r2=1362043&view=diff
==============================================================================
--- qpid/proton/trunk/tests/proton_tests/__init__.py (original)
+++ qpid/proton/trunk/tests/proton_tests/__init__.py Mon Jul 16 14:09:41 2012
@@ -20,3 +20,4 @@
 import proton_tests.engine
 import proton_tests.message
 import proton_tests.messenger
+import proton_tests.sasl

Added: qpid/proton/trunk/tests/proton_tests/sasl.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/proton_tests/sasl.py?rev=1362043&view=auto
==============================================================================
--- qpid/proton/trunk/tests/proton_tests/sasl.py (added)
+++ qpid/proton/trunk/tests/proton_tests/sasl.py Mon Jul 16 14:09:41 2012
@@ -0,0 +1,61 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import os, common, xproton
+from xproton import *
+
+class Test(common.Test):
+  pass
+
+class SaslTest(Test):
+
+  def testPipelined(self):
+    cli = pn_sasl()
+    pn_sasl_mechanisms(cli, "ANONYMOUS")
+    pn_sasl_client(cli)
+
+    srv = pn_sasl()
+    pn_sasl_mechanisms(srv, "ANONYMOUS")
+    pn_sasl_server(srv)
+    pn_sasl_done(srv, PN_SASL_OK)
+
+    cli_code, cli_out = pn_sasl_output(cli, 1024)
+    srv_code, srv_out = pn_sasl_output(srv, 1024)
+
+    assert cli_code > 0, cli_code
+    assert srv_code > 0, srv_code
+
+    dummy_header = "AMQPxxxx"
+
+    srv_out += dummy_header
+    cli_out += dummy_header
+
+    n = pn_sasl_input(srv, cli_out)
+    assert n > 0, n
+    cli_out = cli_out[n:]
+    assert cli_out == dummy_header
+    n = pn_sasl_input(srv, cli_out)
+    assert n == PN_EOS, n
+
+    n = pn_sasl_input(cli, srv_out)
+    assert n > 0, n
+    srv_out = srv_out[n:]
+    assert srv_out == dummy_header
+    n = pn_sasl_input(cli, srv_out)
+    assert n == PN_EOS, n



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org