public void AssociationCreationWithStore() { TestSupport.ResetStores(); // get rid of existing associations so a new one is created OpenIdRelyingParty rp = TestSupport.CreateRelyingParty(null); var directMessageSniffer = new DirectMessageSniffWrapper(rp.DirectMessageChannel); rp.DirectMessageChannel = directMessageSniffer; var idUrl = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20); DotNetOpenId.RelyingParty.IAuthenticationRequest req; bool associationMade = false; directMessageSniffer.Receiving += (provider, fields) => { if (fields.ContainsKey("assoc_handle") && fields.ContainsKey("session_type")) associationMade = true; }; req = rp.CreateRequest(idUrl, realm, returnTo); Assert.IsTrue(associationMade); }
public void MinimumOPVersion20WithDeceptiveEndpointRealizedAtAuthentication() { // Create an identifier that claims to have a 2.0 OP endpoint. MockIdentifier id = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20); var rp = TestSupport.CreateRelyingParty(null, null); IAuthenticationRequest req = rp.CreateRequest(id, TestSupport.Realm, TestSupport.ReturnTo); IResponse providerResponse = TestSupport.CreateProviderResponseToRequest(req, opReq => { opReq.IsAuthenticated = true; }); var opAuthWebResponse = (Response)providerResponse; var opAuthResponse = (DotNetOpenId.Provider.EncodableResponse)opAuthWebResponse.EncodableMessage; var rp2 =TestSupport. CreateRelyingParty(null, opAuthResponse.RedirectUrl, opAuthResponse.EncodedFields.ToNameValueCollection()); rp2.Settings.MinimumRequiredOpenIdVersion = ProtocolVersion.V20; // Rig an intercept between the provider and RP to make our own Provider LOOK like a 1.x provider. var sniffer = new DirectMessageSniffWrapper(rp2.DirectMessageChannel); rp2.DirectMessageChannel = sniffer; sniffer.Receiving += (endpoint, fields) => { fields.Remove(Protocol.v20.openidnp.ns); }; var resp = rp2.Response; Assert.AreEqual(AuthenticationStatus.Failed, resp.Status, "Authentication should have failed since OP is really a 1.x OP masquerading as a 2.0 OP."); }