Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Commit

Permalink
Fixed implementation test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiang committed Jan 27, 2014
1 parent 181241c commit 214fb3c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 0.2.0 (2013-01-27)

- [MINOR]: Added support for DIGEST-MD5 authentication
- [PATCH]: Fixed a bug in xml parser, which triggered wrong events

## 0.1.0 (2014-01-23)

- [MINOR]: First release
1 change: 1 addition & 0 deletions tests/features/authentication.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ Feature: Authentication
And Test response data for digest-md5 auth
When connecting
Then digest-md5 authentication element should be send
And digest-md5 response send
30 changes: 19 additions & 11 deletions tests/features/bootstrap/AuthenticationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testResponseDataForPlain()
. "id='1234567890' from='localhost' version='1.0' xml:lang='en'><stream:features></stream:features>"
));
}

/**
* @Given /^Test response data for authentication failure$/
*/
Expand All @@ -74,15 +74,16 @@ public function testResponseDataForAuthenticationFailure()
"<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>"
));
}

/**
* @Given /^Test response data for digest-md5 auth$/
*/
public function testResponseDataForDigestMdAuth()
{
$this->getConnection()->setData(array(
"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' "
. "id='1234567890' from='localhost' version='1.0' xml:lang='en'><stream:features>"
. "id='1234567890' from='localhost' version='1.0' xml:lang='en'>",
"<stream:features>"
. "<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism></mechanisms>"
. "</stream:features>",
'<challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">'
Expand Down Expand Up @@ -110,16 +111,14 @@ public function plainAuthenticationElementShouldBeSend()
$this->getConnection()->getBuffer()
);
}

/**
* @Then /^digest-md(\d+) authentication element should be send$/
* @Then /^digest-md5 authentication element should be send$/
*/
public function digestMdAuthenticationElementShouldBeSend($arg1)
public function digestMdAuthenticationElementShouldBeSend()
{
assertContains(
'<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="DIGIST-MD5"/>',
$this->getConnection()->getBuffer()
);
$buffer = $this->getConnection()->getBuffer();
assertContains('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="DIGEST-MD5"/>', $buffer[1]);
}


Expand All @@ -130,7 +129,7 @@ public function shouldBeAuthenticated()
{
assertTrue($this->getConnection()->getOptions()->isAuthenticated());
}

/**
* @Then /^a authorization exception should be catched$/
*/
Expand All @@ -142,6 +141,15 @@ public function aAuthorizationExceptionShouldBeCatched()
assertSame('Stream Error: "not-authorized"', $exception->getMessage());
}

/**
* @Then /^digest-md5 response send$/
*/
public function digestMdResponseSend()
{
$buffer = $this->getConnection()->getBuffer();
assertRegExp('#^<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">[\w]+</response>$#', $buffer[2]);
}

/**
*
* @return \Fabiang\Xmpp\Connection\Test
Expand Down

0 comments on commit 214fb3c

Please sign in to comment.