Skip to content

Commit f3e3ec4

Browse files
committed
Add deprecation warning to id() method
Signed-off-by: Wesley Schwengle <waterkip@cpan.org>
1 parent 99bb04c commit f3e3ec4

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

lib/Net/SAML2/SP.pm

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,14 @@ Consumer Services.
162162

163163
has 'url' => (isa => Uri, is => 'ro', required => 1, coerce => 1);
164164

165-
has 'id' => (isa => XsdID, is => 'ro', builder => '_build_id');
166-
has 'issuer' => (isa => 'Str', is => 'ro', required => 1);
165+
has '_id' => (
166+
isa => XsdID,
167+
is => 'ro',
168+
builder => '_build_id',
169+
init_arg => 'id'
170+
);
171+
172+
has 'issuer' => (isa => 'Str', is => 'ro', required => 1);
167173

168174
has 'cert' => (isa => 'Str', is => 'ro', required => 1, predicate => 'has_cert');
169175
has 'key' => (isa => 'Str', is => 'ro', required => 1);
@@ -298,6 +304,14 @@ sub _build_id {
298304
return Net::SAML2::Util::generate_id();
299305
}
300306

307+
sub id {
308+
my $self = shift;
309+
Net::SAML2::Util::deprecation_warning
310+
"id() has been renamed to issuer()";
311+
return $self->issuer;
312+
}
313+
314+
301315
sub _build_encryption_key_text {
302316
my ($self) = @_;
303317

@@ -590,7 +604,7 @@ sub generate_metadata {
590604
$md,
591605
{
592606
entityID => $self->issuer,
593-
ID => $self->id,
607+
ID => $self->_id,
594608
},
595609
$x->SPSSODescriptor(
596610
$md,

t/02-create-sp.t

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,4 +490,18 @@ use URN::OASIS::SAML2 qw(:bindings :urn);
490490
is($child[1]->getAttribute('isRequired'), '1', ".. and requiredness");
491491
}
492492

493+
{
494+
my $sp = net_saml2_sp();
495+
496+
my @warns;
497+
local $SIG{__WARN__} = sub { push(@warns, shift); };
498+
my $id = $sp->id;
499+
is($id, $sp->issuer, "id is still the issuer");
500+
cmp_deeply(
501+
\@warns,
502+
["NET::SAML2 deprecation warning: id() has been renamed to issuer()\n"],
503+
"We have our deprecation warning"
504+
);
505+
}
506+
493507
done_testing;

0 commit comments

Comments
 (0)