public BaseHandlerIntegrationTest() { var _applicationConfiguration = new ApplicationConfiguration(); var configurationRoot = TestHelper.GetConfigurationRoot(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); configurationRoot.Bind(_applicationConfiguration); var consoleWriter = new ConsoleWriter(SerilogFixture.UsefullLogger <ConsoleWriter>()); var authTokenFactory = new OAuthTokenFactory(SerilogFixture.UsefullLogger <OAuthTokenFactory>(), _applicationConfiguration); var clientFactory = new ClientProxyFactory(SerilogFixture.UsefullLogger <ClientProxyFactory>(), authTokenFactory, _applicationConfiguration); //var fileHandler = new FileHandlerMock() {ReadFile = FileHandlerMock.WithReadFileAsNoOp(), WriteFile = FileHandlerMock.WithWriteFileAsNoOp()}.Build(); var fileHandler = new FileHandler(SerilogFixture.UsefullLogger <FileHandler>()); SchemaClient = clientFactory.GetClientProxy <ISquidexAppSchemaClient>("aut-developer"); SchemaImportSystemUnderTest = new SchemaImportHandler(SerilogFixture.UsefullLogger <SchemaImportHandler>(), clientFactory, consoleWriter, null); SchemaExportSystemUnderTest = new SchemaExportHandler(SerilogFixture.UsefullLogger <SchemaExportHandler>(), clientFactory, consoleWriter, null); SchemaDeleteSystemUnderTest = new SchemaDeleteHandler(SerilogFixture.UsefullLogger <SchemaDeleteHandler>(), clientFactory, consoleWriter, null); SchemaListSystemUnderTest = new SchemaListHandler(SerilogFixture.UsefullLogger <SchemaListHandler>(), clientFactory, consoleWriter, null); //var schemaTagHandler = new SchemaTagHandler(SerilogFixture.UsefullLogger<ContentDeleteSystemUnderTest>(), clientFactory, null); ContentClient = clientFactory.GetClientProxy <ISquidexContentClient>("aut-developer"); ContentImportSystemUnderTest = new ContentImportHandler(SerilogFixture.UsefullLogger <ContentImportHandler>(), clientFactory, consoleWriter, null); ContentExportSystemUnderTest = new ContentExportHandler(SerilogFixture.UsefullLogger <ContentExportHandler>(), clientFactory, consoleWriter, null); ContentDeleteSystemUnderTest = new ContentDeleteHandler(SerilogFixture.UsefullLogger <ContentDeleteHandler>(), clientFactory, consoleWriter, null); ContentPostSystemUnderTest = new ContentPostHandler(SerilogFixture.UsefullLogger <ContentImportHandler>(), clientFactory, consoleWriter, null); AttachmentClient = clientFactory.GetClientProxy <ISquidexAttachmentClient>("aut-developer"); AttachmentImportSystemUnderTest = new AssetImportHandler(SerilogFixture.UsefullLogger <AssetImportHandler>(), clientFactory, consoleWriter, null); AttachmentExportSystemUnderTest = new AssetExportHandler(SerilogFixture.UsefullLogger <AssetExportHandler>(), clientFactory, consoleWriter, null); AttachmentDeleteSystemUnderTest = new AssetDeleteHandler(SerilogFixture.UsefullLogger <AssetDeleteHandler>(), clientFactory, consoleWriter, null); AttachmentListSystemUnderTest = new AssetListHandler(SerilogFixture.UsefullLogger <AssetListHandler>(), clientFactory, consoleWriter, null); AttachmentTagSystemUnderTest = new AssetTagHandler(SerilogFixture.UsefullLogger <AssetTagHandler>(), clientFactory, consoleWriter, null); AssetUpdateContentSystemUnderTest = new AssetUpdateContentHandler(SerilogFixture.UsefullLogger <AssetUpdateContentHandler>(), clientFactory, consoleWriter, null); }
public void should_send_request_with_authorization_header_when_actor_has_remembered_access_token() { var actor = ActorFactory.CreateSomeActorWithApiCallAbility(Sender); var token = OAuthTokenFactory.SomeToken(); actor.Remember(TokenConstants.TokenKey, token); actor.AttemptsTo(GetHttpInteraction(Urls.UsersApi)); Check.That(Sender.GetLastSentMessage().Headers.Authorization.Scheme).IsEqualTo(token.TokenType); Check.That(Sender.GetLastSentMessage().Headers.Authorization.Parameter).IsEqualTo(token.AccessToken); }
public void should_send_request_to_correct_url() { const string endpoint = "http://localhost:5000/"; const string username = "******"; const string password = "******"; SetupSuccessfulResponse(OAuthTokenFactory.SomeToken()); actor.AttemptsTo(GetAccessToken .UsingResourceOwnerPasswordCredentialFlow() .WithCredentials(username, password) .FromEndpoint(endpoint)); var lastRequestContent = sender.GetLastSentMessage().RequestUri.AbsoluteUri; Check.That(lastRequestContent).IsEqualTo(endpoint); }
public void actor_should_remember_access_token_after_response() { const string endpoint = "http://localhost:5000/"; const string username = "******"; const string password = "******"; var token = OAuthTokenFactory.SomeToken(); SetupSuccessfulResponse(token); actor.AttemptsTo(GetAccessToken .UsingResourceOwnerPasswordCredentialFlow() .WithCredentials(username, password) .FromEndpoint(endpoint)); var rememberedToken = actor.Recall <OAuthToken>(TokenConstants.TokenKey); Check.That(rememberedToken).HasFieldsWithSameValues(token); }
public void should_send_username_and_password() { const string endpoint = "http://localhost:5000/"; const string username = "******"; const string password = "******"; const string expected = "grant_type=password&username=admin&password=123456"; SetupSuccessfulResponse(OAuthTokenFactory.SomeToken()); actor.AttemptsTo(GetAccessToken .UsingResourceOwnerPasswordCredentialFlow() .WithCredentials(username, password) .FromEndpoint(endpoint)); var lastRequestContent = sender.GetLastSentMessage().Content.ReadAsStringAsync().Result; Check.That(lastRequestContent).IsEqualTo(expected); }