Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify the specs that are really about parsing the XRDS documents

Conflicts:

	framework/src/play/src/test/scala/play/api/libs/openid/DiscoverySpec.scala
  • Loading branch information...
commit 86830b09d9e5068218e0979b15dc1afe1215de68 1 parent 46dfad7
@juretta juretta authored guillaumebort committed
View
95 framework/src/play/src/test/scala/play/api/libs/openid/DiscoverySpec.scala
@@ -94,47 +94,45 @@ object DiscoverySpec extends Specification with Mockito {
val maybeOpenIdServer = new XrdsResolver().resolve(response)
maybeOpenIdServer.map(_.url) must beSome("https://www.google.com/accounts/o8/ud")
}
- }
-
- "Discovery" should {
-
- "resolve an OpenID server via Yadis" in {
- "with a single service element" in {
- val ws = new WSMock
- ws.response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/simple-op.xml"))
- ws.response.header(HeaderNames.CONTENT_TYPE) returns Some("application/xrds+xml")
-
- val returnTo = "http://foo.bar.com/openid"
- val openId = "http://abc.example.com/foo"
- val redirectUrl = Await.result(new OpenIDClient(ws.url).redirectURL(openId, returnTo), dur)
-
- there was one(ws.request).get()
-
- new URL(redirectUrl).hostAndPath must be equalTo "https://www.google.com/a/example.com/o8/ud"
- verifyValidOpenIDRequest(parseQueryString(redirectUrl), openId, returnTo)
- }
+ "parse an XRDS response with a single Service element" in {
+ response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/simple-op.xml"))
+ val maybeOpenIdServer = new XrdsResolver().resolve(response)
+ maybeOpenIdServer.map(_.url) must beSome("https://www.google.com/a/example.com/o8/ud?be=o8")
+ }
- "with multiple service elements" in {
- val ws = new WSMock
- ws.response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/multi-service.xml"))
- ws.response.header(HeaderNames.CONTENT_TYPE) returns Some("application/xrds+xml")
+ "parse an XRDS response with multiple Service elements" in {
+ response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/multi-service.xml"))
+ val maybeOpenIdServer = new XrdsResolver().resolve(response)
+ maybeOpenIdServer.map(_.url) must beSome("http://www.myopenid.com/server")
+ }
- val returnTo = "http://foo.bar.com/openid"
- val openId = "http://abc.example.com/foo"
- val redirectUrl = Await.result(new OpenIDClient(ws.url).redirectURL(openId, returnTo), dur)
+ // See 7.3.2.2. Extracting Authentication Data
+ "return the OP Identifier over the Claimed Identifier if both are present" in {
+ response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/multi-service-with-op-and-claimed-id-service.xml"))
+ val maybeOpenIdServer = new XrdsResolver().resolve(response)
+ maybeOpenIdServer.map(_.url) must beSome("http://openidprovider-opid.example.com")
+ }
- there was one(ws.request).get()
+ "extract and use OpenID Authentication 1.0 service elements from XRDS documents, if Yadis succeeds on an URL Identifier." in {
+ response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/simple-openid-1-op.xml"))
+ val maybeOpenIdServer = new XrdsResolver().resolve(response)
+ maybeOpenIdServer.map(_.url) must beSome("http://openidprovider-server-1.example.com")
+ }
- new URL(redirectUrl).hostAndPath must be equalTo "http://www.myopenid.com/server"
+ "extract and use OpenID Authentication 1.1 service elements from XRDS documents, if Yadis succeeds on an URL Identifier." in {
+ response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/simple-openid-1.1-op.xml"))
+ val maybeOpenIdServer = new XrdsResolver().resolve(response)
+ maybeOpenIdServer.map(_.url) must beSome("http://openidprovider-server-1.1.example.com")
+ }
+ }
- verifyValidOpenIDRequest(parseQueryString(redirectUrl), openId, returnTo)
- }
+ "OpenID.redirectURL" should {
- // See 7.3.2.2. Extracting Authentication Data
- "returning the OP Identifier over the Claimed Identifier if both are present" in {
+ "resolve an OpenID server via Yadis" in {
+ "with a single service element" in {
val ws = new WSMock
- ws.response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/multi-service-with-op-and-claimed-id-service.xml"))
+ ws.response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/simple-op.xml"))
ws.response.header(HeaderNames.CONTENT_TYPE) returns Some("application/xrds+xml")
val returnTo = "http://foo.bar.com/openid"
@@ -143,7 +141,7 @@ object DiscoverySpec extends Specification with Mockito {
there was one(ws.request).get()
- new URL(redirectUrl).hostAndPath must be equalTo "http://openidprovider-opid.example.com"
+ new URL(redirectUrl).hostAndPath must be equalTo "https://www.google.com/a/example.com/o8/ud"
verifyValidOpenIDRequest(parseQueryString(redirectUrl), openId, returnTo)
}
@@ -185,35 +183,6 @@ object DiscoverySpec extends Specification with Mockito {
verifyValidOpenIDRequest(parseQueryString(redirectUrl), openId, returnTo)
}
- "Relying Parties SHOULD extract and use OpenID Authentication 1.0 service elements from XRDS documents, if Yadis succeeds on an URL Identifier." in {
- val ws = new WSMock
- ws.response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/simple-openid-1-op.xml"))
- ws.response.header(HeaderNames.CONTENT_TYPE) returns Some("application/xrds+xml")
-
- val returnTo = "http://foo.bar.com/openid"
- val openId = "http://abc.example.com/foo"
- val redirectUrl = Await.result(new OpenIDClient(ws.url).redirectURL(openId, returnTo), dur)
-
- there was one(ws.request).get()
- new URL(redirectUrl).hostAndPath must be equalTo "http://openidprovider-server-1.example.com"
-
- verifyValidOpenIDRequest(parseQueryString(redirectUrl), openId, returnTo)
- }
-
- "Relying Parties SHOULD extract and use OpenID Authentication 1.1 service elements from XRDS documents, if Yadis succeeds on an URL Identifier." in {
- val ws = new WSMock
- ws.response.xml returns scala.xml.XML.loadString(readFixture("discovery/xrds/simple-openid-1.1-op.xml"))
- ws.response.header(HeaderNames.CONTENT_TYPE) returns Some("application/xrds+xml")
-
- val returnTo = "http://foo.bar.com/openid"
- val openId = "http://abc.example.com/foo"
- val redirectUrl = Await.result(new OpenIDClient(ws.url).redirectURL(openId, returnTo), dur)
-
- there was one(ws.request).get()
- new URL(redirectUrl).hostAndPath must be equalTo "http://openidprovider-server-1.1.example.com"
-
- verifyValidOpenIDRequest(parseQueryString(redirectUrl), openId, returnTo)
- }
}
"resolve an OpenID server via HTML" in {
Please sign in to comment.
Something went wrong with that request. Please try again.