io.restassured.builder.RequestSpecBuilder Java Examples
The following examples show how to use
io.restassured.builder.RequestSpecBuilder.
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: HerdRestUtil.java From herd-mdl with Apache License 2.0 | 7 votes |
private static RequestSpecification getBaseRequestSpecification(User user) { RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); RequestSpecBuilder requestSpecBuilder = new RequestSpecBuilder() .log(LogDetail.ALL) .setRelaxedHTTPSValidation() .setContentType("application/xml"); //Only set authentication when auth is enabled if (BooleanUtils.toBoolean(TestProperties.get(StackInputParameterKeyEnum.ENABLE_SSL_AUTH))) { LOGGER.info("Setting Basic Auth for user: " + user.getUsername()); PreemptiveBasicAuthScheme authenticationScheme = new PreemptiveBasicAuthScheme(); authenticationScheme.setUserName(user.getUsername()); authenticationScheme.setPassword(user.getPassword()); requestSpecBuilder.setAuth(authenticationScheme) .setAuth(authenticationScheme); } return requestSpecBuilder.build().redirects().follow(true); }
Example #2
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 #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: ConfigurationExtension.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
private RequestSpecification defaultRequestSpecification() { RequestSpecBuilder requestSpecification = new RequestSpecBuilder(); requestSpecification.addFilter( new CookieFilter() ); requestSpecification.addFilter( new SessionFilter() ); requestSpecification.addFilter( new AuthFilter() ); requestSpecification.setContentType( ContentType.JSON ); return requestSpecification.build(); }
Example #5
Source File: FakeClassnameTags123Api.java From openapi-generator with Apache License 2.0 | 5 votes |
private RequestSpecBuilder createReqSpec() { RequestSpecBuilder reqSpec = reqSpecSupplier.get(); if(reqSpecCustomizer != null) { reqSpecCustomizer.accept(reqSpec); } return reqSpec; }
Example #6
Source File: AnotherFakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
private RequestSpecBuilder createReqSpec() { RequestSpecBuilder reqSpec = reqSpecSupplier.get(); if(reqSpecCustomizer != null) { reqSpecCustomizer.accept(reqSpec); } return reqSpec; }
Example #7
Source File: JmapJamesServerContract.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach default void setup(GuiceJamesServer server) throws Exception { 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(); }
Example #8
Source File: UserApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void createApi() { api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( () -> new RequestSpecBuilder() .setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson()))) .addFilter(new ErrorLoggingFilter()) .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); }
Example #9
Source File: VertxProducerResourceTest.java From quarkus with Apache License 2.0 | 5 votes |
@Test public void testRouteRegistrationMTLS() { RequestSpecification spec = new RequestSpecBuilder() .setBaseUri(String.format("%s://%s", url.getProtocol(), url.getHost())) .setPort(url.getPort()) .setKeyStore("client-keystore.jks", "password") .setTrustStore("client-truststore.jks", "password") .build(); given().spec(spec).get("/my-path").then().body(containsString("OK")); }
Example #10
Source File: IntegrationTest.java From vertx-in-action with MIT License | 5 votes |
@BeforeAll static void prepareSpec() { requestSpecification = new RequestSpecBuilder() .addFilters(asList(new ResponseLoggingFilter(), new RequestLoggingFilter())) .setBaseUri("http://localhost:3000/") .build(); }
Example #11
Source File: IntegrationTest.java From prebid-server-java with Apache License 2.0 | 5 votes |
static RequestSpecification spec(int port) { return new RequestSpecBuilder() .setBaseUri("http://localhost") .setPort(port) .setConfig(RestAssuredConfig.config() .objectMapperConfig(new ObjectMapperConfig(new Jackson2Mapper((aClass, s) -> mapper)))) .build(); }
Example #12
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 #13
Source File: UserApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void createApi() { api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( () -> new RequestSpecBuilder() .setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(jackson()))) .addFilter(new ErrorLoggingFilter()) .setBaseUri("http://petstore.swagger.io:80/v2"))).user(); }
Example #14
Source File: StoreApi.java From openapi-generator with Apache License 2.0 | 5 votes |
private RequestSpecBuilder createReqSpec() { RequestSpecBuilder reqSpec = reqSpecSupplier.get(); if(reqSpecCustomizer != null) { reqSpecCustomizer.accept(reqSpec); } return reqSpec; }
Example #15
Source File: FixingGhostMailboxTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setup(GuiceJamesServer server) throws Throwable { WebAdminGuiceProbe webAdminProbe = server.getProbe(WebAdminGuiceProbe.class); mailboxProbe = server.getProbe(MailboxProbeImpl.class); aclProbe = server.getProbe(ACLProbeImpl.class); Port jmapPort = server.getProbe(JmapGuiceProbe.class).getJmapPort(); RestAssured.requestSpecification = new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setPort(jmapPort.getValue()) .build(); RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); webadminSpecification = WebAdminUtils.buildRequestSpecification(webAdminProbe.getWebAdminPort()) .build(); server.getProbe(DataProbeImpl.class).fluent() .addDomain(DOMAIN) .addUser(ALICE, ALICE_SECRET) .addUser(BOB, BOB_SECRET); accessToken = authenticateJamesUser(baseUri(jmapPort), Username.of(ALICE), ALICE_SECRET); CassandraProbe probe = server.getProbe(CassandraProbe.class); ClusterConfiguration cassandraConfiguration = probe.getConfiguration(); try (Cluster cluster = ClusterFactory.create(cassandraConfiguration)) { try (Session session = cluster.connect(probe.getMainKeyspaceConfiguration().getKeyspace())) { simulateGhostMailboxBug(session); } } }
Example #16
Source File: StoreApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void createApi() { api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( () -> new RequestSpecBuilder() .setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(gson()))) .addFilter(new ErrorLoggingFilter()) .setBaseUri("http://petstore.swagger.io:80/v2"))).store(); }
Example #17
Source File: HTTPConfigurationServerTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() { mailRepository = new ReceivedMailRepository(); server = HTTPConfigurationServer.onRandomPort(new SMTPBehaviorRepository(), mailRepository) .start(); RestAssured.requestSpecification = new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setPort(server.getPort().getValue()) .setBasePath("/smtpMails") .build(); }
Example #18
Source File: FakeApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void createApi() { api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier( () -> new RequestSpecBuilder() .setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(jackson()))) .addFilter(new ErrorLoggingFilter()) .setBaseUri("http://petstore.swagger.io:80/v2"))).fake(); }
Example #19
Source File: LinshareTest.java From james-project with Apache License 2.0 | 5 votes |
@BeforeEach void setup() { RestAssured.requestSpecification = new RequestSpecBuilder() .setContentType(ContentType.JSON) .setAccept(ContentType.JSON) .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8))) .setBaseUri("http://" + linshareExtension.getLinshare().getIp()) .setPort(linshareExtension.getLinshare().getPort()) .build(); RestAssured.enableLoggingOfRequestAndResponseIfValidationFails(); }
Example #20
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 4 votes |
public CreateXmlItemOper(RequestSpecBuilder reqSpec) { this.reqSpec = reqSpec; reqSpec.setContentType("application/xml"); reqSpec.setAccept("application/json"); this.respSpec = new ResponseSpecBuilder(); }
Example #21
Source File: UserApi.java From openapi-generator with Apache License 2.0 | 4 votes |
private UserApi(Supplier<RequestSpecBuilder> reqSpecSupplier) { this.reqSpecSupplier = reqSpecSupplier; }
Example #22
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 4 votes |
public DeletePetOper(RequestSpecBuilder reqSpec) { this.reqSpec = reqSpec; reqSpec.setAccept("application/json"); this.respSpec = new ResponseSpecBuilder(); }
Example #23
Source File: UserApi.java From openapi-generator with Apache License 2.0 | 4 votes |
public CreateUsersWithListInputOper(RequestSpecBuilder reqSpec) { this.reqSpec = reqSpec; reqSpec.setContentType("*/*"); reqSpec.setAccept("application/json"); this.respSpec = new ResponseSpecBuilder(); }
Example #24
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 4 votes |
public FindPetsByTagsOper(RequestSpecBuilder reqSpec) { this.reqSpec = reqSpec; reqSpec.setAccept("application/json"); this.respSpec = new ResponseSpecBuilder(); }
Example #25
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 4 votes |
public FindPetsByStatusOper(RequestSpecBuilder reqSpec) { this.reqSpec = reqSpec; reqSpec.setAccept("application/json"); this.respSpec = new ResponseSpecBuilder(); }
Example #26
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 4 votes |
public DeletePetOper(RequestSpecBuilder reqSpec) { this.reqSpec = reqSpec; reqSpec.setAccept("application/json"); this.respSpec = new ResponseSpecBuilder(); }
Example #27
Source File: UserApi.java From openapi-generator with Apache License 2.0 | 4 votes |
public UpdateUserOper(RequestSpecBuilder reqSpec) { this.reqSpec = reqSpec; reqSpec.setContentType("*/*"); reqSpec.setAccept("application/json"); this.respSpec = new ResponseSpecBuilder(); }
Example #28
Source File: FakeClassnameTags123Api.java From openapi-generator with Apache License 2.0 | 4 votes |
public TestClassnameOper(RequestSpecBuilder reqSpec) { this.reqSpec = reqSpec; reqSpec.setContentType("application/json"); reqSpec.setAccept("application/json"); this.respSpec = new ResponseSpecBuilder(); }
Example #29
Source File: FakeClassnameTags123Api.java From openapi-generator with Apache License 2.0 | 4 votes |
private FakeClassnameTags123Api(Supplier<RequestSpecBuilder> reqSpecSupplier) { this.reqSpecSupplier = reqSpecSupplier; }
Example #30
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 4 votes |
public UploadFileWithRequiredFileOper(RequestSpecBuilder reqSpec) { this.reqSpec = reqSpec; reqSpec.setContentType("multipart/form-data"); reqSpec.setAccept("application/json"); this.respSpec = new ResponseSpecBuilder(); }