From fdf6861d58ace85b6115a9318fabc29f18f96b04 Mon Sep 17 00:00:00 2001 From: Francesco Giacomini <giaco at cnaf dot infn dot it> Date: Wed, 14 Mar 2018 17:36:52 +0100 Subject: [PATCH] [wip] generic attributes: fix test and code --- src/ngx_http_voms_module.cpp | 8 +++++--- t/voms_generic_attributes.t | 13 +++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/ngx_http_voms_module.cpp b/src/ngx_http_voms_module.cpp index dd3a21c..d03bfa4 100644 --- a/src/ngx_http_voms_module.cpp +++ b/src/ngx_http_voms_module.cpp @@ -374,7 +374,7 @@ std::string get_voms_not_after(VomsAc const& ac) static std::string encode(attribute const& a) { - return "n" + a.name + " v=" + a.value + " q=" + a.qualifier; + return "n=" + a.name + " v=" + a.value + " q=" + a.qualifier; } std::string get_voms_generic_attributes(VomsAc const& ac) @@ -387,10 +387,12 @@ std::string get_voms_generic_attributes(VomsAc const& ac) auto& gas = attributes.front().attributes; bool first = true; for (auto& a : gas) { - result += encode(a); - if (!first) { + if (first) { + first = false; + } else { result += ','; } + result += encode(a); } } diff --git a/t/voms_generic_attributes.t b/t/voms_generic_attributes.t index 832c6bf..b1f1ca6 100644 --- a/t/voms_generic_attributes.t +++ b/t/voms_generic_attributes.t @@ -5,7 +5,7 @@ run_tests(); __DATA__ -=== TEST 1: https with x509 client authentication, verification of valid VOMS attributes extracted by ngx_http_voms_module +=== TEST 1: valid AC, including generic attributes --- main_config env OPENSSL_ALLOW_PROXY_CERTS=1; env X509_VOMS_DIR=t/vomsdir; @@ -46,11 +46,12 @@ GET / /C=IT/O=IGI/CN=test0 /C=IT/O=IGI/CN=Test CA /test/exp1,/test/exp2,/test/exp3/Role=PIPPO -/C=IT/O=IGI/CN=nginx-voms.example +/C=IT/O=IGI/CN=voms.example /C=IT/O=IGI/CN=Test CA test.vo -2018-01-01T00:00:00 -2030-01-01T00:00:00 -nickname = newland (test.vo),nickname = giaco (test.vo) -1644758975 +voms.example:15000 +20180101000000Z +20300101000000Z +n=nickname v=newland q=test.vo,n=nickname v=giaco q=test.vo +0 --- error_code: 200 -- GitLab