public void GetServer() { ServersWithAuthorizationCode.CleanUpForTests(); var server1 = ServersWithAuthorizationCode.Add("myfunnyid", "myfunnysecret", new Uri("http://example.com/AuthorizationRequest"), new Uri("http://example.com/AccessRequest"), new Uri("http://example.com/RedirectionUri")); var server2 = ServersWithAuthorizationCode.Add("myfunnyid2", "myfunnysecret", new Uri("http://example.com/AuthorizationRequest2"), new Uri("http://example.com/AccessRequest2"), new Uri("http://example.com/RedirectionUri2")); server2.Version = Server.OAuthVersion.v2_22; var server1Result = ServersWithAuthorizationCode.GetServerWithAuthorizationCode(server1.Guid); Assert.AreEqual(server1, server1Result); Assert.IsTrue(ServersWithAuthorizationCode.ServerWithAuthorizationCodeExists(server1.Guid)); var server2Result = ServersWithAuthorizationCode.GetServerWithAuthorizationCode(server2.ClientId, server2.AuthorizationRequestUri, server2.AccessTokenRequestUri, server2.RedirectionUri); Assert.AreEqual(server2, server2Result); Assert.IsTrue(ServersWithAuthorizationCode.ServerWithAuthorizationCodeExists(server2.ClientId, server2.AuthorizationRequestUri, server2.AccessTokenRequestUri, server2.RedirectionUri)); var resourceOwnerNull = ServersWithAuthorizationCode.GetServerWithAuthorizationCode(Guid.NewGuid()); Assert.IsNull(resourceOwnerNull); Assert.IsFalse(ServersWithAuthorizationCode.ServerWithAuthorizationCodeExists(Guid.NewGuid())); }
public void DisposeAndLoad() { ServersWithAuthorizationCode.CleanUpForTests(); var server1 = ServersWithAuthorizationCode.Add("server1", "afunnysecret", new Uri("http://example.org/uri1"), new Uri("http://example.org/uri2"), new Uri("http://example.org/uri3"), new List <String>() { "scopedmaskl", "scope2" }); ServersWithAuthorizationCode.Add("server2", "afunnysecret", new Uri("http://example.org/uri4"), new Uri("http://example.org/uri5"), new Uri("http://example.org/uri6")); ServersWithAuthorizationCode.SaveToIsoStore(); ServersWithAuthorizationCode.LoadFromIsoStore(); var server = ServersWithAuthorizationCode.GetServerWithAuthorizationCode(server1.Guid); server.Should().NotBeNull(); server.ClientId.Should().Be("server1"); server.AuthorizationRequestUri.ToString().Should().Be("http://example.org/uri1"); server.AccessTokenRequestUri.ToString().Should().Be("http://example.org/uri2"); server.RedirectionUri.ToString().Should().Be("http://example.org/uri3"); server.Scopes.FirstOrDefault(item => item == "scopedmaskl").Should().NotBeNull(); server.Scopes.FirstOrDefault(item => item == "scope2").Should().NotBeNull(); var serverNull = ServersWithAuthorizationCode.GetServerWithAuthorizationCode(Guid.NewGuid()); serverNull.Should().BeNull(); }
public void CreateServerDouble() { ServersWithAuthorizationCode.CleanUpForTests(); var serverWithAuth = ServersWithAuthorizationCode.Add("myfunnyid", "myfunnysecret", new Uri("http://example.com/AuthorizationRequest"), new Uri("http://example.com/access"), new Uri("http://example.com/RedirectionUri")); Assert.IsNotNull(serverWithAuth); Assert.AreEqual("myfunnyid", serverWithAuth.ClientId); ServersWithAuthorizationCode.Add("myfunnyid", "myfunnysecret", new Uri("http://example.com/AuthorizationRequest"), new Uri("http://example.com/access"), new Uri("http://example.com/RedirectionUri")); }
public void SetUp() { Tokens.CleanUpForTests(); ResourceOwners.CleanUpForTests(); ServersWithAuthorizationCode.CleanUpForTests(); var authorizationRequestUri = new Uri("http://example.org/GetAccessAndRefreshTokenTest/Authorization"); var accessTokenUri = new Uri("http://example.org/GetAccessAndRefreshTokenTest/Access"); var redirectionUri = new Uri("http://example.org/GetAccessAndRefreshTokenTest/redirectionUri"); _server = ServersWithAuthorizationCode.Add("123456789", "testsecret", authorizationRequestUri, accessTokenUri, redirectionUri); _resourceOwner = ResourceOwners.Add("Test"); _token = Tokens.GetToken(_server, _resourceOwner); _token.RedirectUri = _server.RedirectionUri; _token.AuthorizationCode = "Aplx10BeZQQYbYS6WxSbIA"; }
public void CreateServer() { ServersWithAuthorizationCode.CleanUpForTests(); var serverWithAuth = ServersWithAuthorizationCode.Add("myfunnyid", "myfunnysecret", new Uri("http://example.com/AuthorizationRequest"), new Uri("http://example.com/access"), new Uri("http://example.com/RedirectionUri")); serverWithAuth.Should().NotBeNull(); serverWithAuth.ClientId.Should().Be("myfunnyid"); serverWithAuth.ClientSharedSecret.Should().Be("myfunnysecret"); serverWithAuth.AuthorizationRequestUri.ToString().Should().Be("http://example.com/AuthorizationRequest"); serverWithAuth.RedirectionUri.ToString().Should().Be("http://example.com/RedirectionUri"); serverWithAuth.Guid.Should().NotBeEmpty(); serverWithAuth.Guid.ToString().Should().NotBe(new Guid().ToString()); serverWithAuth.Scopes.Should().NotBeNull(); }
public void SetUp() { ResourceOwners.CleanUpForTests(); ServersWithAuthorizationCode.CleanUpForTests(); Tokens.CleanUpForTests(); }