Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
Welcome to the Monastery
 
PerlMonks  

SOAP initialization?

by Anonymous Monk
on Aug 02, 2012 at 00:52 UTC ( #984924=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a question concerning SOAP::Lite initialization.

I have a self-written module where the constructor accepts two parameters for the username & password and then sets a couple of variables at module scope:

my ($_username, $_password); sub new { my ($username, $password) = @_; $_username = $username; $_password = $password; my $self = {}; # ... bless $self; }

These two module variables are then used in the overloading of SOAP::Transport::HTTP::Client which is used in authentication:

sub SOAP::Transport::HTTP::Client::get_basic_credentials { return $_username => $_password; }

The reason for pushing this into the module is because it being used in a Test::More script & the SOAP's complexities are to be hidden in the module.

Typically, a new module instance is used for running a battery of tests. Execution is made of a number of tests which all authenticate fine using one module instance in one subroutine is followed by creating a new module instance using bad credentials before executing another series of tests which should all intentionally fail in yet a different subroutine.

At least, this is what I intended. I assumed that placing different module instances each in their own subroutines would take care of any lingering scoping issues. I thought I could reset authentication upon the creation of each new module instance.

What I am seeing in practice is if an instance of the module is created using a correct username/password pair, all tests associated with that instance succeed as expected. What is unexpected is if I then create a new instance of the module with a bad username/password pair, all associated tests still pass because authentication was successful.

If I then go back to the initial set of tests (originally intended to pass...), & set the username/password incorrectly, those tests all fail as expected. Creation of another module instance with bad credentials causes all subsequent tests to fail as is expected.

Am I correct to assume that the username/password is getting cached? If so, is there a way I can reinitialize SOAP::Lite such that I can use my module as intended toggling authentication as intended? Any suggestions would be greatly appreciated.

Thanks!

Comment on SOAP initialization?
Select or Download Code
Re: SOAP initialization?
by Anonymous Monk on Aug 02, 2012 at 07:56 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://984924]
Approved by bulk88
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (18)
As of 2013-06-20 12:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many continents have you visited?









    Results (685 votes), past polls