xs/request.xs

filter: Statementstmt 95.8% 23 / 24 Branchbran 62.5% 10 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 82.5% 33 / 40 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/psaml/psaml_time.h ↑ Summary include/psaml/psaml_metadata.h »
1 MODULE = Punk::SAML PACKAGE = Punk::SAML::Request
2  
3 # The outbound half, driven directly so the suite exercises it with no
4 # application booted. Phase 8 calls the same functions from the login
5 # route with values off the application hash.
6  
7 SV *
8 new_id(class)
9 SV *class
10 CODE:
11 PERL_UNUSED_VAR(class);
12 50 RETVAL = psaml_request_id(aTHX);
13 OUTPUT:
14 RETVAL
15  
16 # build(%args): the AuthnRequest document.
17 SV *
18 build(class, ...)
19 SV *class
20 CODE:
21 HV *a;
22 int i;
23 PERL_UNUSED_VAR(class);
24 8 ▶ if ((items - 1) % 2)
Branch: 1 branch
BranchTrueFalseTotal
if ((items - 1) % 2) 0 8 8
25 0 croak("%s: Request->build takes a list of pairs", PSAML_WHO);
26 8 a = newHV();
27 8 sv_2mortal((SV *)a);
28 52 ▶ for (i = 1; i + 1 < items; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 1; i + 1 < items; i += 2) { 44 8 52
29 STRLEN kl;
30 44 const char *k = SvPV_const(ST(i), kl);
31 44 (void)hv_store(a, k, (I32)kl, newSVsv(ST(i + 1)), 0);
32 }
33 8 RETVAL = psaml_authn_request(aTHX_
34 psaml_hget(aTHX_ a, "id"),
35 psaml_hget(aTHX_ a, "instant"),
36 psaml_hget(aTHX_ a, "destination"),
37 psaml_hget(aTHX_ a, "acs_url"),
38 psaml_hget(aTHX_ a, "issuer"),
39 psaml_hget(aTHX_ a, "name_id_format"),
40 psaml_opt_bool(aTHX_ a, "force_authn", 0));
41 OUTPUT:
42 RETVAL
43  
44 # redirect_url($sso_url, $xml, $relay, $key_pem): the full 302 target.
45 SV *
46 redirect_url(class, sso_url, xml, relay = &PL_sv_undef, key_pem = &PL_sv_undef)
47 SV *class
48 SV *sso_url
49 SV *xml
50 SV *relay
51 SV *key_pem
52 CODE:
53 PERL_UNUSED_VAR(class);
54 6 RETVAL = psaml_redirect_url(aTHX_ sso_url, xml, relay, key_pem);
55 OUTPUT:
56 RETVAL
57  
58 MODULE = Punk::SAML PACKAGE = Punk::SAML
59  
60 # The pieces, for t/. Not public API: the leading underscore says so.
61  
62 SV *
63 _urlenc(str)
64 SV *str
65 CODE:
66 8 RETVAL = psaml_urlenc(aTHX_ str);
67 OUTPUT:
68 RETVAL
69  
70 SV *
71 _deflate_b64(bytes)
72 SV *bytes
73 CODE:
74 1 RETVAL = psaml_deflate_b64(aTHX_ bytes);
75 OUTPUT:
76 RETVAL
77  
78 # The signed string of Bindings 3.4.4.1, over values ALREADY encoded, so a
79 # test can check the order and the omission of RelayState without having
80 # to reach inside redirect_url.
81 SV *
82 _signed_string(enc_req, enc_relay, enc_sigalg)
83 SV *enc_req
84 SV *enc_relay
85 SV *enc_sigalg
86 CODE:
87 2 RETVAL = psaml_signed_string(aTHX_ enc_req,
88 2 ▶ (SvOK(enc_relay) && SvCUR(enc_relay)) ? enc_relay : NULL,
Branch: 2 branches
BranchTrueFalseTotal
(SvOK(enc_relay) && SvCUR(enc_relay)) ? enc_relay : NULL, 2 0 2
(SvOK(enc_relay) && SvCUR(enc_relay)) ? enc_relay : NULL, 1 1 2
89 enc_sigalg);
90 OUTPUT:
91 RETVAL
92  
93 SV *
94 _decode_field(field, max_bytes)
95 SV *field
96 IV max_bytes
97 CODE:
98 7 RETVAL = psaml_decode_field(aTHX_ field, max_bytes);
99 OUTPUT:
100 RETVAL
101  
102 # Verify a detached signature over raw bytes, for t/.
103 #
104 # This is the gap phase 2 deferred: jws_abi's `verify` takes raw signing
105 # input, but Crypt::JWS's PERL surface insists on a compact token, so a
106 # Perl caller holding a detached signature has no way in. Punk::SAML is
107 # an XS consumer and reaches the table directly, so the test for the
108 # redirect signature goes through here rather than waiting for
109 # Crypt::JWS to grow verify_bytes.
110 int
111 _verify_bytes(pub_pem, alg, input, sig)
112 SV *pub_pem
113 SV *alg
114 SV *input
115 SV *sig
116 CODE:
117 4 const jws_abi *J = psaml_jws(aTHX);
118 STRLEN pl, al, il, sl;
119 4 ▶ const char *pp = SvPVbyte(pub_pem, pl);
Branch: 1 branch
BranchTrueFalseTotal
const char *pp = SvPVbyte(pub_pem, pl); 4 0 4
120 4 ▶ const char *ap = SvPVbyte(alg, al);
Branch: 1 branch
BranchTrueFalseTotal
const char *ap = SvPVbyte(alg, al); 4 0 4
121 4 ▶ const char *ip = SvPVbyte(input, il);
Branch: 1 branch
BranchTrueFalseTotal
const char *ip = SvPVbyte(input, il); 4 0 4
122 4 const char *gp = SvPVbyte(sig, sl);
123 4 void *k = J->key_from_pem(aTHX_ pp, pl);
124 4 ▶ if (!k) croak("%s: the public key will not parse", PSAML_WHO);
Branch: 1 branch
BranchTrueFalseTotal
if (!k) croak("%s: the public key will not parse", PSAML_WHO); 0 4 4
125 4 RETVAL = J->verify(aTHX_ k, ap, al,
126 (const unsigned char *)ip, il,
127 (const unsigned char *)gp, sl);
128 4 J->key_free(aTHX_ k);
129 OUTPUT:
130 RETVAL
« include/psaml/psaml_time.h ↑ Summary include/psaml/psaml_metadata.h »