public void testFindOpEndpointsForUser_throughSiteXrds_SignatureInHeader()
throws Exception {
UrlIdentifier user = new UrlIdentifier("http://balfanz.net/openid?id=12345");
URI siteXrdsUri = URI.create("http://example.com/xrds");
FetchRequest httpRequest = FetchRequest.createGetRequest(siteXrdsUri);
VerificationResult verification = new VerificationResult(
ImmutableList.of(
CertConstantUtil.SERVER_PUB_CERT,
CertConstantUtil.INTERMEDIATE_PUB_CERT));
FakeResponse siteResponse = new FakeResponse(SITE_XRD);
siteResponse.setSignature("siteSig");
FakeResponse userResponse = new FakeResponse(USER_XRD);
userResponse.setSignature("userSig");
expect(fetcher.fetch(httpRequest)).andReturn(siteResponse);
expect(verifier.verify(aryEq(SITE_XRD.getBytes()), eq("siteSig")))
.andReturn(verification);
expect(validator.matches(CertConstantUtil.SERVER_PUB_CERT, "balfanz.net"))
.andReturn(Boolean.TRUE);
String userXrdsUri = "https://www.google.com/accounts/o8/user-xrds?uri="
+ URLEncoder.encode(user.getIdentifier(), "UTF-8");
FetchRequest nextRequest = FetchRequest.createGetRequest(
URI.create(userXrdsUri));
expect(fetcher.fetch(nextRequest)).andReturn(userResponse);
expect(verifier.verify(aryEq(USER_XRD.getBytes()), eq("userSig")))
.andReturn(verification);