Java Code Examples for io.restassured.RestAssured#requestSpecification()
The following examples show how to use
io.restassured.RestAssured#requestSpecification() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ESReporterTest.java From james-project with Apache License 2.0 | 6 votes |
@BeforeEach void setup(GuiceJamesServer server) throws Exception { server.getProbe(DataProbeImpl.class) .fluent() .addDomain(DOMAIN) .addUser(USERNAME, PASSWORD); RestAssured.requestSpecification = new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setPort(server.getProbe(JmapGuiceProbe.class).getJmapPort().getValue()) .build(); accessToken = authenticateJamesUser(baseUri(server), Username.of(USERNAME), PASSWORD); timer = new Timer(); }
Example 2
Source File: MappingRoutesTest.java From james-project with Apache License 2.0 | 6 votes |
@BeforeEach void setUp() throws DomainListException { JsonTransformer jsonTransformer = new JsonTransformer(); recipientRewriteTable = new MemoryRecipientRewriteTable(); DNSService dnsService = mock(DNSService.class); DomainList domainList = new MemoryDomainList(dnsService); domainList.addDomain(Domain.of("domain.tld")); domainList.addDomain(Domain.of("aliasdomain.tld")); domainList.addDomain(Domain.of("domain.mapping.tld")); domainList.addDomain(Domain.of("abc")); domainList.addDomain(Domain.of("xyz")); recipientRewriteTable.setDomainList(domainList); webAdminServer = WebAdminUtils.createWebAdminServer(new MappingRoutes(jsonTransformer, recipientRewriteTable)) .start(); RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer) .setBasePath(MappingRoutes.BASE_PATH) .log(LogDetail.METHOD) .build(); }
Example 3
Source File: MailRepositoriesRoutesTest.java From james-project with Apache License 2.0 | 6 votes |
@Test public void downloadingAMailShouldFailWhenUnknown() throws Exception { mailRepositoryStore.create(URL_MY_REPO); RestAssured.requestSpecification = new RequestSpecBuilder().setPort(webAdminServer.getPort().getValue()) .setBasePath(MailRepositoriesRoutes.MAIL_REPOSITORIES) .build(); RestAssured.registerParser(Constants.RFC822_CONTENT_TYPE, Parser.TEXT); String name = "name"; given() .accept(Constants.RFC822_CONTENT_TYPE) .when() .get(PATH_ESCAPED_MY_REPO + "/mails/" + name) .then() .statusCode(HttpStatus.NOT_FOUND_404) .body("statusCode", is(404)) .body("type", is(ErrorResponder.ErrorType.NOT_FOUND.getType())) .body("message", is("Could not retrieve " + name)); }
Example 4
Source File: QuotaMailingTest.java From james-project with Apache License 2.0 | 6 votes |
@Before public void setup() throws Throwable { jmapServer = createJmapServer(); jmapServer.start(); MailboxProbe mailboxProbe = jmapServer.getProbe(MailboxProbeImpl.class); DataProbe dataProbe = jmapServer.getProbe(DataProbeImpl.class); quotaProbe = jmapServer.getProbe(QuotaProbesImpl.class); RestAssured.requestSpecification = jmapRequestSpecBuilder .setPort(jmapServer.getProbe(JmapGuiceProbe.class).getJmapPort().getValue()) .build(); RestAssured.defaultParser = Parser.JSON; dataProbe.addDomain(DOMAIN); dataProbe.addUser(HOMER.asString(), PASSWORD); dataProbe.addUser(BART.asString(), BOB_PASSWORD); mailboxProbe.createMailbox("#private", HOMER.asString(), DefaultMailboxes.INBOX); homerAccessToken = authenticateJamesUser(baseUri(jmapServer), HOMER, PASSWORD); bartAccessToken = authenticateJamesUser(baseUri(jmapServer), BART, BOB_PASSWORD); }
Example 5
Source File: SetMessagesOutboxFlagUpdateTest.java From james-project with Apache License 2.0 | 6 votes |
@Before public void setup() throws Throwable { jmapServer = createJmapServer(); jmapServer.start(); MailboxProbe mailboxProbe = jmapServer.getProbe(MailboxProbeImpl.class); DataProbe dataProbe = jmapServer.getProbe(DataProbeImpl.class); RestAssured.requestSpecification = new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setPort(jmapServer.getProbe(JmapGuiceProbe.class).getJmapPort().getValue()) .build(); RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); RestAssured.defaultParser = Parser.JSON; dataProbe.addDomain(DOMAIN); dataProbe.addUser(USERNAME.asString(), PASSWORD); dataProbe.addUser(BOB.asString(), BOB_PASSWORD); mailboxProbe.createMailbox("#private", USERNAME.asString(), DefaultMailboxes.INBOX); accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(jmapServer), USERNAME, PASSWORD); }
Example 6
Source File: EventDeadLettersRoutesTest.java From james-project with Apache License 2.0 | 6 votes |
@BeforeEach void beforeEach() { deadLetters = new MemoryEventDeadLetters(); JsonTransformer jsonTransformer = new JsonTransformer(); EventSerializer eventSerializer = new EventSerializer(new InMemoryId.Factory(), new InMemoryMessageId.Factory(), new DefaultUserQuotaRootResolver.DefaultQuotaRootDeserializer()); eventBus = new InVMEventBus(new InVmEventDelivery(new RecordingMetricFactory()), RetryBackoffConfiguration.DEFAULT, deadLetters); EventDeadLettersRedeliverService redeliverService = new EventDeadLettersRedeliverService(eventBus, deadLetters); EventDeadLettersService service = new EventDeadLettersService(redeliverService, deadLetters); taskManager = new MemoryTaskManager(new Hostname("foo")); webAdminServer = WebAdminUtils.createWebAdminServer( new EventDeadLettersRoutes(service, eventSerializer, taskManager, jsonTransformer), new TasksRoutes(taskManager, jsonTransformer, DTOConverter.of(EventDeadLettersRedeliveryTaskAdditionalInformationForOne.module(), EventDeadLettersRedeliveryTaskAdditionalInformationForGroup.module(), EventDeadLettersRedeliveryTaskAdditionalInformationForAll.module()))) .start(); RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer).build(); RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); }
Example 7
Source File: RabbitMQWebAdminServerTaskSerializationIntegrationTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setUp(GuiceJamesServer guiceJamesServer) throws Exception { dataProbe = guiceJamesServer.getProbe(DataProbeImpl.class); dataProbe.addDomain(DOMAIN); WebAdminGuiceProbe webAdminGuiceProbe = guiceJamesServer.getProbe(WebAdminGuiceProbe.class); mailboxProbe = guiceJamesServer.getProbe(MailboxProbeImpl.class); RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminGuiceProbe.getWebAdminPort()) .build(); RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); }
Example 8
Source File: JMAPApiRoutesTest.java From james-project with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { requestHandler = mock(RequestHandler.class); mockedAuthFilter = mock(Authenticator.class); mockedUserProvisionner = mock(UserProvisioner.class); mockedMailboxesProvisionner = mock(DefaultMailboxesProvisioner.class); JMAPApiRoutes jmapApiRoutes = new JMAPApiRoutes(requestHandler, new RecordingMetricFactory(), mockedAuthFilter, mockedUserProvisionner, mockedMailboxesProvisionner); JMAPRoute postApiRoute = jmapApiRoutes.routes() .filter(jmapRoute -> jmapRoute.getEndpoint().getMethod().equals(HttpMethod.POST)) .findFirst() .get(); server = HttpServer.create() .port(RANDOM_PORT) .route(routes -> routes.post(postApiRoute.getEndpoint().getPath(), (req, res) -> postApiRoute.getAction().handleRequest(req, res))) .bindNow(); RestAssured.requestSpecification = new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setPort(server.port()) .setBasePath(JMAP) .build(); doReturn(Mono.just(MailboxSessionUtil.create(Username.of("bob")))) .when(mockedAuthFilter).authenticate(any()); when(mockedUserProvisionner.provisionUser(any())) .thenReturn(Mono.empty()); when(mockedMailboxesProvisionner.createMailboxesIfNeeded(any())) .thenReturn(Mono.empty()); }
Example 9
Source File: AuthorizedEndpointsTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setUp(GuiceJamesServer guiceJamesServer) { WebAdminGuiceProbe webAdminGuiceProbe = guiceJamesServer.getProbe(WebAdminGuiceProbe.class); RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminGuiceProbe.getWebAdminPort()) .build(); }
Example 10
Source File: ForwardRoutesTest.java From james-project with Apache License 2.0 | 5 votes |
private void createServer(ForwardRoutes forwardRoutes) { webAdminServer = WebAdminUtils.createWebAdminServer(forwardRoutes) .start(); RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer) .setBasePath("address/forwards") .log(LogDetail.METHOD) .build(); }
Example 11
Source File: SieveScriptRoutesTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setUp(TemporaryFolderExtension.TemporaryFolder temporaryFolder) throws Exception { FileSystem fileSystem = new FileSystem() { @Override public File getBasedir() { return temporaryFolder.getTempDir(); } @Override public InputStream getResource(String url) throws IOException { return new FileInputStream(getFile(url)); } @Override public File getFile(String fileURL) { return new File(getBasedir(), fileURL.substring(FileSystem.FILE_PROTOCOL.length())); } }; sieveRepository = new SieveFileRepository(fileSystem); UsersRepository usersRepository = MemoryUsersRepository.withoutVirtualHosting(NO_DOMAIN_LIST); usersRepository.addUser(Username.of("userA"), "password"); URL sieveResource = ClassLoader.getSystemResource("sieve/my_sieve"); sieveContent = IOUtils.toString(sieveResource, StandardCharsets.UTF_8); webAdminServer = WebAdminUtils.createWebAdminServer(new SieveScriptRoutes(sieveRepository, usersRepository)) .start(); RestAssured.requestSpecification = WebAdminUtils .buildRequestSpecification(webAdminServer) .build(); }
Example 12
Source File: CorsHeaderAPITest.java From james-project with Apache License 2.0 | 5 votes |
@Before public void setup() throws Throwable { jmapServer = createJmapServer(); jmapServer.start(); RestAssured.requestSpecification = jmapRequestSpecBuilder .setPort(jmapServer.getProbe(JmapGuiceProbe.class).getJmapPort().getValue()) .build(); RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); DataProbe dataProbe = jmapServer.getProbe(DataProbeImpl.class); dataProbe.addDomain(DOMAIN); dataProbe.addUser(ALICE.asString(), ALICE_PASSWORD); accessToken = authenticateJamesUser(baseUri(jmapServer), ALICE, ALICE_PASSWORD); }
Example 13
Source File: RecomputeUserFastViewProjectionItemsRequestToTaskTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() throws Exception { JsonTransformer jsonTransformer = new JsonTransformer(); taskManager = new MemoryTaskManager(new Hostname("foo")); messageFastViewProjection = new MemoryMessageFastViewProjection(new RecordingMetricFactory()); mailboxManager = InMemoryIntegrationResources.defaultResources().getMailboxManager(); usersRepository = MemoryUsersRepository.withoutVirtualHosting(NO_DOMAIN_LIST); usersRepository.addUser(BOB, "pass"); bobSession = mailboxManager.createSystemSession(BOB); bobInboxboxId = mailboxManager.createMailbox(MailboxPath.inbox(BOB), bobSession) .get(); MessageContentExtractor messageContentExtractor = new MessageContentExtractor(); HtmlTextExtractor htmlTextExtractor = new JsoupHtmlTextExtractor(); Preview.Factory previewFactory = new Preview.Factory(messageContentExtractor, htmlTextExtractor); MessageFastViewPrecomputedProperties.Factory projectionItemFactory = new MessageFastViewPrecomputedProperties.Factory(previewFactory); webAdminServer = WebAdminUtils.createWebAdminServer( new TasksRoutes(taskManager, jsonTransformer, DTOConverter.of(RecomputeUserFastViewTaskAdditionalInformationDTO.module())), new JMAPRoutes( new MessageFastViewProjectionCorrector(usersRepository, mailboxManager, messageFastViewProjection, projectionItemFactory), taskManager, usersRepository)) .start(); RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer) .setBasePath("/bob/mailboxes") .log(LogDetail.URI) .build(); }
Example 14
Source File: RabbitMQEventDeadLettersIntegrationTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setUp(GuiceJamesServer guiceJamesServer) throws Exception { DataProbe dataProbe = guiceJamesServer.getProbe(DataProbeImpl.class); mailboxProbe = guiceJamesServer.getProbe(MailboxProbeImpl.class); WebAdminGuiceProbe webAdminGuiceProbe = guiceJamesServer.getProbe(WebAdminGuiceProbe.class); RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminGuiceProbe.getWebAdminPort()) .build(); dataProbe.addDomain(DOMAIN); dataProbe.addUser(BOB, BOB_PASSWORD); }
Example 15
Source File: DomainQuotaRoutesTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setUp(WebAdminQuotaSearchTestSystem testSystem) throws Exception { testSystem.getQuotaSearchTestSystem().getDomainList() .addDomain(FOUND_LOCAL); maxQuotaManager = testSystem.getQuotaSearchTestSystem().getMaxQuotaManager(); RestAssured.requestSpecification = testSystem.getRequestSpecification(); RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); }
Example 16
Source File: SetVacationResponseTest.java From james-project with Apache License 2.0 | 5 votes |
@Before public void setup() throws Throwable { jmapServer = createJmapServer(); jmapServer.start(); jmapGuiceProbe = jmapServer.getProbe(JmapGuiceProbe.class); RestAssured.requestSpecification = jmapRequestSpecBuilder .setPort(jmapGuiceProbe.getJmapPort().getValue()) .build(); jmapServer.getProbe(DataProbeImpl.class) .fluent() .addDomain(DOMAIN) .addUser(USER, PASSWORD); accessToken = authenticateJamesUser(baseUri(jmapServer), Username.of(USER), PASSWORD); }
Example 17
Source File: JMAPServerTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { VersionParser versionParser = new VersionParser(SUPPORTED_VERSIONS); server = new JMAPServer(TEST_CONFIGURATION, FAKE_ROUTES_HANDLERS, versionParser); server.start(); RestAssured.requestSpecification = new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setPort(server.getPort().getValue()) .build(); }
Example 18
Source File: GuiceLifecycleHeathCheckTest.java From james-project with Apache License 2.0 | 5 votes |
private static void configureRequestSpecification(GuiceJamesServer server) { WebAdminGuiceProbe webAdminGuiceProbe = server.getProbe(WebAdminGuiceProbe.class); RestAssured.requestSpecification = new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setPort(webAdminGuiceProbe.getWebAdminPort().getValue()) .build(); }
Example 19
Source File: DeletedMessageVaultIntegrationTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setup(GuiceJamesServer jmapServer) throws Throwable { MailboxProbe mailboxProbe = jmapServer.getProbe(MailboxProbeImpl.class); DataProbe dataProbe = jmapServer.getProbe(DataProbeImpl.class); Port jmapPort = jmapServer.getProbe(JmapGuiceProbe.class).getJmapPort(); RestAssured.requestSpecification = jmapRequestSpecBuilder .setPort(jmapPort.getValue()) .build(); RestAssured.defaultParser = Parser.JSON; dataProbe.addDomain(DOMAIN); dataProbe.addUser(HOMER, PASSWORD); dataProbe.addUser(BART, BOB_PASSWORD); dataProbe.addUser(JACK, PASSWORD); mailboxProbe.createMailbox("#private", HOMER, DefaultMailboxes.INBOX); otherMailboxId = mailboxProbe.createMailbox("#private", HOMER, MAILBOX_NAME); homerAccessToken = authenticateJamesUser(baseUri(jmapPort), Username.of(HOMER), PASSWORD); bartAccessToken = authenticateJamesUser(baseUri(jmapPort), Username.of(BART), BOB_PASSWORD); jackAccessToken = authenticateJamesUser(baseUri(jmapPort), Username.of(JACK), PASSWORD); testIMAPClient = new TestIMAPClient(); webAdminApi = WebAdminUtils.spec(jmapServer.getProbe(WebAdminGuiceProbe.class).getWebAdminPort()) .config(WebAdminUtils.defaultConfig() .paramConfig(new ParamConfig(REPLACE, REPLACE, REPLACE))); }
Example 20
Source File: MailboxesRoutesTest.java From james-project with Apache License 2.0 | 4 votes |
@BeforeEach void beforeEach() throws Exception { client = MailboxIndexCreationUtil.prepareDefaultClient( elasticSearch.getDockerElasticSearch().clientProvider().get(), elasticSearch.getDockerElasticSearch().configuration()); InMemoryMessageId.Factory messageIdFactory = new InMemoryMessageId.Factory(); MailboxIdRoutingKeyFactory routingKeyFactory = new MailboxIdRoutingKeyFactory(); InMemoryIntegrationResources resources = InMemoryIntegrationResources.builder() .preProvisionnedFakeAuthenticator() .fakeAuthorizator() .inVmEventBus() .defaultAnnotationLimits() .defaultMessageParser() .listeningSearchIndex(preInstanciationStage -> new ElasticSearchListeningMessageSearchIndex( preInstanciationStage.getMapperFactory(), new ElasticSearchIndexer(client, MailboxElasticSearchConstants.DEFAULT_MAILBOX_WRITE_ALIAS, BATCH_SIZE), new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), SEARCH_SIZE, new InMemoryId.Factory(), messageIdFactory, MailboxElasticSearchConstants.DEFAULT_MAILBOX_READ_ALIAS, routingKeyFactory), new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES), preInstanciationStage.getSessionProvider(), routingKeyFactory)) .noPreDeletionHooks() .storeQuotaManager() .build(); mailboxManager = resources.getMailboxManager(); messageIdManager = resources.getMessageIdManager(); taskManager = new MemoryTaskManager(new Hostname("foo")); InMemoryId.Factory mailboxIdFactory = new InMemoryId.Factory(); searchIndex = spy((ListeningMessageSearchIndex) resources.getSearchIndex()); ReIndexerPerformer reIndexerPerformer = new ReIndexerPerformer( mailboxManager, searchIndex, mailboxManager.getMapperFactory()); ReIndexer reIndexer = new ReIndexerImpl( reIndexerPerformer, mailboxManager, mailboxManager.getMapperFactory()); JsonTransformer jsonTransformer = new JsonTransformer(); webAdminServer = WebAdminUtils.createWebAdminServer( new TasksRoutes(taskManager, jsonTransformer, DTOConverter.of( WebAdminErrorRecoveryIndexationDTO.serializationModule(mailboxIdFactory), WebAdminFullIndexationDTO.serializationModule(mailboxIdFactory), WebAdminSingleMailboxReindexingTaskAdditionalInformationDTO.serializationModule(mailboxIdFactory), SingleMessageReindexingTaskAdditionalInformationDTO.module(mailboxIdFactory))), new MailboxesRoutes(taskManager, jsonTransformer, ImmutableSet.of( new MailboxesRoutes.ReIndexAllMailboxesTaskRegistration( reIndexer, new PreviousReIndexingService(taskManager), mailboxIdFactory)), ImmutableSet.of( new MailboxesRoutes.ReIndexOneMailboxTaskRegistration( reIndexer, mailboxIdFactory)), ImmutableSet.of( new MailboxesRoutes.ReIndexOneMailTaskRegistration( reIndexer, mailboxIdFactory)))) .start(); RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer).build(); RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); }