@@ -1348,6 +1348,40 @@ describe( 'passport-saml /', function() {
1348
1348
}
1349
1349
} ) ;
1350
1350
} ) ;
1351
+
1352
+ it ( 'XML AttributeValue should return object' , function ( done ) {
1353
+ const nameid_opaque_string = '*******************************'
1354
+ const nameQualifier = 'https://idp.example.org/idp/saml'
1355
+ const spNameQualifier = 'https://sp.example.org/sp/entity'
1356
+ const format = 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
1357
+ const xml =
1358
+ '<Response>' +
1359
+ '<saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" Version="2.0">' +
1360
+ '<saml2:AttributeStatement>' +
1361
+ '<saml2:Attribute FriendlyName="eduPersonTargetedID" Name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">' +
1362
+ '<saml2:AttributeValue>' +
1363
+ '<saml2:NameID Format="' + format + '" NameQualifier="' + nameQualifier + '" SPNameQualifier="' + spNameQualifier + '">' +
1364
+ nameid_opaque_string +
1365
+ '</saml2:NameID>' +
1366
+ '</saml2:AttributeValue>' +
1367
+ '</saml2:Attribute>' +
1368
+ '</saml2:AttributeStatement>' +
1369
+ '</saml2:Assertion>' +
1370
+ '</Response>' ;
1371
+ var base64xml = Buffer . from ( xml ) . toString ( 'base64' ) ;
1372
+ var container = { SAMLResponse : base64xml } ;
1373
+ var samlObj = new SAML ( ) ;
1374
+ samlObj . validatePostResponse ( container , function ( err , profile , logout ) {
1375
+ should . not . exist ( err ) ;
1376
+ const eptid = profile [ 'urn:oid:1.3.6.1.4.1.5923.1.1.1.10' ] ;
1377
+ const nameid = eptid [ 'NameID' ] [ 0 ]
1378
+ nameid . _ . should . eql ( nameid_opaque_string )
1379
+ nameid . $ . NameQualifier . should . equal ( nameQualifier )
1380
+ nameid . $ . SPNameQualifier . should . equal ( spNameQualifier )
1381
+ nameid . $ . Format . should . equal ( format )
1382
+ done ( ) ;
1383
+ } ) ;
1384
+ } ) ;
1351
1385
} ) ;
1352
1386
1353
1387
0 commit comments