### Install and Build Translator Bundle Source: https://github.com/usebruno/bruno-docs/blob/main/tools/translator-bundle/README.md Commands to install dependencies and build the translator bundle from the repository root. ```bash npm install npm run build:translator ``` -------------------------------- ### Install Bruno CLI with npm Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/installation.mdx Installs the Bruno CLI globally using the npm package manager. Ensure Node.js is installed. ```bash npm install -g @usebruno/cli ``` -------------------------------- ### Install Bruno CLI with pnpm Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/installation.mdx Installs the Bruno CLI globally using the pnpm package manager. Ensure Node.js is installed. ```bash pnpm install -g @usebruno/cli ``` -------------------------------- ### Install Bruno CLI with yarn Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/installation.mdx Installs the Bruno CLI globally using the yarn package manager. Ensure Node.js is installed. ```bash yarn global add @usebruno/cli ``` -------------------------------- ### Install Mintlify CLI Source: https://github.com/usebruno/bruno-docs/blob/main/README.md Installs the Mintlify CLI globally using npm. This command is required to manage and develop the documentation site. Ensure Node.js version 19 or higher is installed. ```shell npm install -g mint ``` -------------------------------- ### Bitbucket Repository URL Example Source: https://github.com/usebruno/bruno-docs/blob/main/git-integration/bitbucket.mdx This is an example of a Bitbucket repository URL format. Use this when adding a remote to your local repository. ```bash git@bitbucket.org:/.git ``` -------------------------------- ### Verify Bruno CLI Installation Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/quick-start.mdx Check if the Bruno CLI is installed correctly by running the version command. This should output the installed version number. ```bash bru --version ``` -------------------------------- ### Start Bruno Docs Development Server Source: https://github.com/usebruno/bruno-docs/blob/main/README.md Starts the local development server for the Bruno documentation using the Mintlify CLI. The site will be accessible at http://localhost:3000. ```shell mint dev ``` -------------------------------- ### Install Bruno CLI with npm Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/quick-start.mdx Install the Bruno CLI globally using npm. This command makes the 'bru' command available in your terminal. ```bash npm install -g @usebruno/cli ``` -------------------------------- ### Example TOML Email Template Source: https://github.com/usebruno/bruno-docs/blob/main/license-administrators/self-hosted-licensing.mdx An example of a TOML file for an email template, including subject and HTML body with variables. ```toml subject = "Your Bruno License Key - {{orgName}}" body = ''' Bruno License Key

Welcome to {{orgName}}!

Hello {{name}},

Your Bruno license key is ready:

{{licenseKey}}

Please keep this license key secure and do not share it with anyone.

If you have any questions, please contact our support team.


© {{currentYear}} {{orgName}}. Powered by Bruno.

''' ``` -------------------------------- ### Clone Bruno Starter Guide Repository Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/quick-start.mdx Clone the sample collection repository to follow the walkthrough. Navigate into the cloned directory. ```bash git clone https://github.com/bruno-collections/bruno-starter-guide.git cd bruno-starter-guide ``` -------------------------------- ### Install Bruno CLI with pnpm Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/quick-start.mdx Install the Bruno CLI globally using pnpm. This command makes the 'bru' command available in your terminal. ```bash pnpm install -g @usebruno/cli ``` -------------------------------- ### GraphQL Query Example Source: https://github.com/usebruno/bruno-docs/blob/main/send-requests/graphql/graphql-api.mdx This is an example GraphQL query to fetch album data. It can be tested against the provided GraphQL API endpoint. ```graphql query Albums { albums { data { id title } } } ``` -------------------------------- ### Install Bruno CLI with yarn Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/quick-start.mdx Install the Bruno CLI globally using yarn. This command makes the 'bru' command available in your terminal. ```bash yarn global add @usebruno/cli ``` -------------------------------- ### Okta fullName Configuration Example Source: https://github.com/usebruno/bruno-docs/blob/main/license-administrators/saml-sso/troubleshooting.mdx Example configuration for setting the 'fullName' attribute in Okta, combining first and last names. This ensures Bruno receives the user's full name. ```text Name: fullName Name format: Unspecified Value: user.firstName+" "+user.lastName Alternative: user.displayName ``` -------------------------------- ### Example Global Environment Configuration Source: https://github.com/usebruno/bruno-docs/blob/main/variables/global-environment-variables.mdx This YAML file defines a global environment named 'development' with an 'api_url' variable. ```yaml name: development variables: - name: api_url value: http://localhost:3000 enabled: true secret: false type: text ``` -------------------------------- ### Install Bruno CLI in GitHub Actions Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/quick-start.mdx Installs the Bruno CLI globally using npm. This is a prerequisite for running Bruno commands in a CI environment. ```yaml - name: Install Bruno CLI run: npm install -g @usebruno/cli ``` -------------------------------- ### Client Certificate JSON Configuration Example Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/proxyConfiguration.mdx Example JSON structure for client certificate configuration, including certs and pfx files. ```json { "enabled": true, "certs": [ { "domain": "usebruno.com", "type": "cert", "certFilePath": "certs/server_1.crt", "keyFilePath": "private/server_1.key", "passphrase": "Iu$eBrun0_#Secure!" }, { "domain": "the-example.com", "type": "pfx", "pfxFilePath": "pfx/server_3.pfx", "passphrase": "L!ghT_Y@g@mi_2024!" } ] } ``` -------------------------------- ### Workspace Structure Example Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/github-actions/overview.mdx Demonstrates a typical workspace organization for Bruno automation, including collections, environments, and reports. ```directory bruno-automation-demo-workspace/ ├── .github/ │ └── workflows/ │ └── bruno-api-tests.yml ├── collections/ │ └── bruno-automation-demo/ │ ├── 01-smoke-checks/ │ ├── 02-ci-workflow/ │ ├── 03-release-gates/ │ ├── environments/ │ │ ├── ci.bru │ │ ├── local.bru │ │ └── staging.bru │ └── opencollection.yml ├── environments/ │ ├── ci.yml │ ├── local.yml │ └── staging.yml ├── workspace.yml └── reports/ ``` -------------------------------- ### GET Request with Headers YAML Source: https://github.com/usebruno/bruno-docs/blob/main/opencollection-yaml/samples.mdx Demonstrates how to include custom headers in an HTTP GET request. This is useful for authentication, content negotiation, or passing metadata. ```yaml info: name: Get with Headers type: http seq: 2 http: method: GET url: https://api.example.com/data headers: - name: Content-Type value: application/json - name: Authorization value: Bearer topsecret settings: encodeUrl: true ``` -------------------------------- ### Full Request Object Example Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/request/request-object.mdx Provides a comprehensive example of a `req` object, showcasing its various properties including assertions, authentication, headers, method, script, URL, and variables. It also demonstrates accessing these properties. ```javascript // Example request object const req = { assertions: [], auth: { username: 'myUsername', password: 'mySuperPassword' }, headers: { authorization: 'Bearer ', 'content-type': 'application/json', accept: 'application/json', // Add more headers as needed... }, method: 'GET', mode: 'none', responseType: 'arraybuffer', script: { req: "// Create an array of objects\nconst data = [\n { i…q); const myVariable = bru.getEnvVar('password');" }, signal: {}, url: '{{base.url}}/users/2?queryTest=queryResult', vars: {} }; // Accessing request properties console.log(req.method); // Output: "GET" console.log(req.url); // Output: "{{base.url}}/users/2?queryTest=queryResult" console.log(req.headers.authorization); // Output: "Bearer " console.log(req.auth.username); // Output: "myUsername" ``` -------------------------------- ### Example POST Request in .bru Format Source: https://github.com/usebruno/bruno-docs/blob/main/opencollection-yaml/overview.mdx Presents the equivalent of the OpenCollection YAML example, but in the native `.bru` file format. This allows for direct comparison of the syntax and structure between the two formats. ```bru meta { name: Create User type: http seq: 1 } post { url: https://api.example.com/users body: json auth: inherit } body:json { { "name": "John Doe", "email": "john@doe.com" } } tests { test("should return 201", function() { expect(res.status).to.equal(201); }); } ``` -------------------------------- ### ag-grid Example Source: https://github.com/usebruno/bruno-docs/blob/main/advanced-guides/visualize.mdx This will render a table using the ag-grid provider with filters enabled on all columns. ```javascript const rowData = [ { name: 'John Doe', age: 28, email: 'john@example.com', city: 'New York' }, { name: 'Jane Smith', age: 32, email: 'jane@example.com', city: 'London' } ]; const columnDefinitions = [ { field: "name", filter: true, floatingFilter: true }, { field: "age", filter: true, floatingFilter: true }, { field: "email", filter: true, floatingFilter: true }, { field: "city", filter: true, floatingFilter: true } ]; bru.visualize('table', { name: 'table1', provider: 'ag-grid', props: { rowData, columnDefinitions } }); ``` -------------------------------- ### Get and Use Runtime Variable using JavaScript Source: https://github.com/usebruno/bruno-docs/blob/main/variables/runtime-variables.mdx Retrieves the value of a previously set runtime variable using `bru.getVar()` and utilizes it within a pre-request script. This example demonstrates setting an 'Authorization' header dynamically using a stored token. The `bru.getVar()` function takes the variable name as a string argument and returns its value. ```javascript const token = bru.getVar("token"); req.setHeader("Authorization", `Bearer ${token}`); ``` -------------------------------- ### Download Sample Proxy Configuration Collection Source: https://github.com/usebruno/bruno-docs/blob/main/get-started/configure/proxy-config.mdx Use this button to download a sample collection that demonstrates various proxy setups in action. ```jsx import { BrunoButton } from "/snippets/BrunoButton.jsx"; ``` -------------------------------- ### Display Help for Bruno CLI Options Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/commandOptions.mdx Execute this command to view a comprehensive list of all available options and their usage information for Bruno CLI. ```bash bru run -h ``` -------------------------------- ### Mount Custom Templates with Docker Source: https://github.com/usebruno/bruno-docs/blob/main/license-administrators/self-hosted-licensing.mdx Demonstrates how to mount a local 'templates' directory into the license server container using Docker. ```bash docker run -d \ -e MONGODB_URI="{{ mongodb_uri }}" \ -e SMTP_HOST="{{ smtp_host }}" \ -e SMTP_PORT="{{ smtp_port }}" \ -e SMTP_USER="{{ smtp_user }}" \ -e SMTP_PASSWORD="{{ smtp_password }}" \ -e AUTH_JWT_SECRET="{{ random_uuid }}" \ -e BRUNO_GLOBAL_LICENSE_SERVER_URL="https://license-api.usebruno.com" \ -e PORT="80" \ -p 8080:80 \ -v ~/templates:/opt/license-service/templates \ public.ecr.aws/e6d0f8t6/bruno-hosted-license-server ``` -------------------------------- ### Run Licensing Server Docker Container Source: https://github.com/usebruno/bruno-docs/blob/main/license-administrators/self-hosted-licensing.mdx Execute this command to start the licensing server as a Docker container. Ensure all required environment variables are set. ```bash docker run -d \ -e MONGODB_URI="{{ mongodb_uri }}" \ -e SMTP_HOST="{{ smtp_host }}" \ -e SMTP_PORT="{{ smtp_port }}" \ -e SMTP_USER="{{ smtp_user }}" \ -e SMTP_PASSWORD="{{ smtp_password }}" \ -e AUTH_JWT_SECRET="{{ random_uuid }}" \ -e BRUNO_GLOBAL_LICENSE_SERVER_URL="https://license-api.usebruno.com" \ -e PORT="80" \ -p 8080:80 \ public.ecr.aws/e6d0f8t6/bruno-hosted-license-server ``` -------------------------------- ### Install csv-parse Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/external-libraries.mdx Install the csv-parse npm package. ```bash npm install csv-parse ``` -------------------------------- ### Authentication: Basic Source: https://github.com/usebruno/bruno-docs/blob/main/opencollection-yaml/structure-reference.mdx Sets up basic authentication with a username and password. ```yaml # Basic authentication auth: type: basic username: admin password: secret ``` -------------------------------- ### Choose an Environment with Docker Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/docker.mdx Execute your collection using a specific environment by passing the `--env` flag. ```bash docker run --rm -v $(pwd):/bruno usebruno/cli run --env staging ``` -------------------------------- ### Start Docker Compose Service Source: https://github.com/usebruno/bruno-docs/blob/main/license-administrators/self-hosted-licensing.mdx Command to start the services defined in your docker-compose.yml file in detached mode. ```bash docker-compose up -d ``` -------------------------------- ### SAML Attribute Statement Example Source: https://github.com/usebruno/bruno-docs/blob/main/license-administrators/saml-sso/overview.mdx Example XML structure for defining roles and fullName attributes within a SAML assertion. ```xml admin user.firstName+" "+user.lastName ``` -------------------------------- ### Import OpenAPI to Directory (Classic .bru Layout) Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/import.mdx Imports an OpenAPI specification into a directory and uses the classic .bru file layout for the collection. This requires specifying the --collection-format=bru flag. ```bash bru import openapi \ --source \ --output \ --collection-name "Petstore API" \ --collection-format=bru ``` -------------------------------- ### Get HTTP Method Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Returns the HTTP method of the current request (e.g., GET, POST). Useful for logging or conditional logic. ```javascript const method = req.getMethod(); console.log("HTTP method:", method); // Output: "POST" ``` -------------------------------- ### Petstore API Example URL Source: https://github.com/usebruno/bruno-docs/blob/main/open-api/importOAS.mdx A public URL for a sample OpenAPI specification of the Petstore API, useful for testing import functionality. ```text https://petstore3.swagger.io/api/v3/openapi.json ``` -------------------------------- ### Ansible Playbook for Licensing Server Setup Source: https://github.com/usebruno/bruno-docs/blob/main/license-administrators/self-hosted-licensing.mdx This Ansible playbook automates the process of pulling the Docker image and running the licensing server container on target hosts. ```yaml - hosts: all become: true tasks: - name: Pull Docker image for licensing server docker_image: name: public.ecr.aws/e6d0f8t6/bruno-hosted-license-server source: pull - name: Run the licensing server container docker_container: name: licensing_server image: public.ecr.aws/e6d0f8t6/bruno-hosted-license-server state: started restart_policy: always ports: - "8080:8080" env: MONGODB_URI: "{{ mongodb_uri }}" SMTP_HOST: "{{ smtp_host }}" SMTP_PORT: "{{ smtp_port }}" SMTP_USER: "{{ smtp_user }}" SMTP_PASSWORD: "{{ smtp_pass }}" AUTH_JWT_SECRET: "{{ random_uuid }}" BRUNO_GLOBAL_LICENSE_SERVER_URL: "https://license-api.usebruno.com" PORT: 80 ``` -------------------------------- ### Add Cookie with Options Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Example of adding a cookie using the async `add` method, specifying various attributes like path and maxAge. ```javascript await bru.cookies.add({ key: "session", value: res.body.sessionId, path: "/", maxAge: 3600 }); ``` -------------------------------- ### Run License Server Container with SSL Source: https://github.com/usebruno/bruno-docs/blob/main/license-administrators/self-hosted-licensing.mdx Use this command to run the self-hosted license server container. Ensure the SSL certificate files are mounted correctly and SSL-related environment variables are set if needed. ```bash docker run -d \ -e MONGODB_URI="{{ mongodb_uri }}" \ -e SMTP_HOST="{{ smtp_host }}" \ -e SMTP_PORT="{{ smtp_port }}" \ -e SMTP_USER="{{ smtp_user }}" \ -e SMTP_PASSWORD="{{ smtp_password }}" \ -e AUTH_JWT_SECRET="{{ random_uuid }}" \ -e BRUNO_GLOBAL_LICENSE_SERVER_URL="https://license-api.usebruno.com" \ -e PORT="80" \ -p 8080:80 \ -v ~/ssl:/opt/license-service/ssl \ -e SSL_KEY_PASSPHRASE="secret" \ public.ecr.aws/e6d0f8t6/bruno-hosted-license-server ``` -------------------------------- ### Example SAML Attribute for Full Name Source: https://github.com/usebruno/bruno-docs/blob/main/license-administrators/saml-sso/troubleshooting.mdx This is an example of how the 'fullName' attribute might appear in a SAML response. Bruno prefers this attribute for user identification. ```xml John Doe ``` -------------------------------- ### Get Iteration Data by Key or All Data Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Retrieve a specific field's value using its key, or get all data for the current row as an object if no key is provided. ```javascript const username = bru.runner.iterationData.get("username"); console.log(`Current username: ${username}`); ``` ```javascript const allData = bru.runner.iterationData.get(); console.log("All iteration data:", allData); ``` -------------------------------- ### Generate a Report with Docker Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/docker.mdx Use the `--reporter-junit` flag to generate a JUnit XML report of your collection run. ```bash docker run --rm -v $(pwd):/bruno usebruno/cli run --reporter-junit results.xml ``` -------------------------------- ### Perform Basic GET Request Source: https://github.com/usebruno/bruno-docs/blob/main/bru-lang/samples.mdx Demonstrates a simple GET request to a public API endpoint. This snippet defines the HTTP method and the target URL. ```bru get { url: https://api.github.com/users/usebruno } ``` -------------------------------- ### Get Request Body with JavaScript Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Retrieve the request body using `req.getBody()`. By default, it returns a parsed object for JSON content types. Use `{ raw: true }` to get the raw string. ```javascript // Get the parsed body object (for JSON content type) const body = req.getBody(); console.log("Body title:", body.title); // Output: "Bruno" // Get raw body string (useful for non-JSON or binary data) const rawBody = req.getBody({ raw: true }); console.log("Raw body:", rawBody); // Output: '{"title":"Bruno","role":"Developer"}' ``` -------------------------------- ### Set Cookie using Jar (Simple) Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Demonstrates setting a cookie using the jar API with URL, name, and value. ```javascript const jar = bru.cookies.jar(); jar.setCookie("https://example.com", "sessionId", "abc123"); ``` -------------------------------- ### Configure Bruno CLI with Docker Compose Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/docker.mdx Define and run the Bruno CLI service using Docker Compose. This example mounts local directories for collections and reports, and configures multiple reporters. ```yaml services: bruno-cli: image: usebruno/cli:latest volumes: - ./collection:/bruno - ./reports:/reports command: run . -r --env ci --reporter-json /reports/results.json --reporter-junit /reports/results.xml --reporter-html /reports/results.html ``` -------------------------------- ### GET Request with Query Parameters YAML Source: https://github.com/usebruno/bruno-docs/blob/main/opencollection-yaml/samples.mdx Shows how to append query parameters to a GET request URL. This is commonly used for filtering, sorting, or pagination of API resources. ```yaml info: name: Search Users type: http seq: 3 http: method: GET url: https://api.example.com/users?filter=active&limit=10&page=1 params: - name: filter value: active type: query - name: limit value: "10" type: query - name: page value: "1" type: query settings: encodeUrl: true timeout: 0 followRedirects: true maxRedirects: 5 ``` -------------------------------- ### Basic GET Request YAML Source: https://github.com/usebruno/bruno-docs/blob/main/opencollection-yaml/samples.mdx Defines a simple HTTP GET request to fetch user data from an API. It includes basic request details like method, URL, and settings. ```yaml info: name: Get User type: http seq: 1 http: method: GET url: https://api.github.com/users/usebruno settings: encodeUrl: true ``` -------------------------------- ### Initialize Git Repository for Bruno Collection Source: https://github.com/usebruno/bruno-docs/blob/main/introduction/quick-start.mdx Turn your Bruno collection folder into a Git repository to enable version control and collaboration. ```bash https://github.com/<>/bruno-starter-guide.git ``` -------------------------------- ### Entra ID fullName Configuration Example Source: https://github.com/usebruno/bruno-docs/blob/main/license-administrators/saml-sso/troubleshooting.mdx Example configuration for setting the 'fullName' attribute in Entra ID using a transformation to join user's given name and surname. This is an alternative if a direct 'fullName' attribute is not available. ```text Claim name: fullName Source: Transformation Transformation: Join() Parameter 1: user.givenname Separator: (space) Parameter 2: user.surname Alternative: Use user.displayname if available and properly formatted ``` -------------------------------- ### Use Environment File for Collection Run Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/commandOptions.mdx Specify a path to an environment file (e.g., .bru or .json) using --env-file for your collection run. ```bash bru run --env-file [string] ``` -------------------------------- ### GET Request with Path Parameters YAML Source: https://github.com/usebruno/bruno-docs/blob/main/opencollection-yaml/samples.mdx Illustrates the use of path parameters in a GET request URL. Path parameters are typically used to identify specific resources, like a user by their ID. ```yaml info: name: Get User by ID type: http seq: 4 http: method: GET url: https://api.example.com/users/:id params: - name: id value: "" type: path settings: encodeUrl: true timeout: 0 followRedirects: true maxRedirects: 5 ``` -------------------------------- ### req.getHost() Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Get the hostname from the request URL. ```APIDOC ## req.getHost() ### Description Get the hostname from the request URL. ### Method ```javascript req.getHost() ``` ### Returns - `string`: The hostname of the request URL. ``` -------------------------------- ### GitHub Actions Workflow Example Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/github-actions/overview.mdx This workflow triggers on pull requests and pushes, checks out the repository, and uses the Bruno CLI action to run tests. ```yaml name: API Tests on: [pull_request, push] jobs: bruno: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: usebruno/bruno-cli-action@v1 with: working-directory: tests/payments command: 'run --env prod' ``` -------------------------------- ### req.getExecutionPlatform Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Gets the current execution platform: `app` or `cli`. ```APIDOC ## req.getExecutionPlatform ### Description Get the platform: `app` (desktop) or `cli` (Bruno CLI). ### Method `req.getExecutionPlatform() ### Returns - `string` - The current execution platform (`app` or `cli`). ### Code Example ```javascript const platform = req.getExecutionPlatform(); console.log(`Request is running on ${platform} platform`); ``` ``` -------------------------------- ### Run a Bruno Collection with Docker Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/docker.mdx Mount the current directory to `/bruno` inside the container to run collections. Choose the appropriate command for your shell. ```bash docker run --rm -v $(pwd):/bruno usebruno/cli run ``` ```powershell docker run --rm -v ${PWD}:/bruno usebruno/cli run ``` ```cmd docker run --rm -v %cd%:/bruno usebruno/cli run ``` -------------------------------- ### req.getExecutionMode Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Gets the current execution mode: `runner` or `standalone`. ```APIDOC ## req.getExecutionMode ### Description Get the current active execution mode: `runner` (collection run) or `standalone` (single request). ### Method `req.getExecutionMode() ### Returns - `string` - The current execution mode (`runner` or `standalone`). ### Code Example ```javascript const executionMode = req.getExecutionMode(); console.log(`Request is running in ${executionMode} mode`); ``` ``` -------------------------------- ### Configure Client Certificate for Connection Security Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/commandOptions.mdx Provide the path to a client certificate configuration file using --client-cert-config to secure the connection. ```bash bru run --client-cert-config ``` -------------------------------- ### Response URL Accessor Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Method to get the final URL of the response after any redirects. ```APIDOC ## res.getUrl() ### Description Gets the final URL of the response after all redirects have been followed. This is equivalent to `res.url`. ### Method `res.getUrl()` ### Returns - **string** - The final URL of the response. ``` -------------------------------- ### Get Request Hostname - JavaScript Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Retrieves the hostname from the current request URL. ```javascript const host = req.getHost(); console.log("Host:", host); // Example output: "api.example.com" ``` -------------------------------- ### Build and Run Custom Docker Image Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/docker.mdx After creating a Dockerfile, build your custom image and then run it to execute your Bruno tests. This is useful for creating distributable test suites. ```bash docker build -t my-team/api-tests:v1 . docker run --rm my-team/api-tests:v1 ``` -------------------------------- ### Import OpenAPI to Directory (OpenCollection Layout) Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/import.mdx Imports an OpenAPI specification into a directory using the default OpenCollection YAML layout. Specify the source OpenAPI file, output directory, and an optional collection name. ```bash bru import openapi \ --source \ --output \ --collection-name "Petstore API" ``` -------------------------------- ### Programmatic WSDL to Bruno Conversion (JavaScript) Source: https://github.com/usebruno/bruno-docs/blob/main/converters/wsdl-to-bruno.mdx Convert WSDL files to Bruno collections programmatically using the `@usebruno/converters` package. This involves reading the WSDL file, converting it, and writing the output to a JSON file. Ensure you have installed the package using 'npm install @usebruno/converters'. ```javascript const { wsdlToBruno } = require('@usebruno/converters'); const { readFile, writeFile } = require('fs/promises'); async function convertWsdlToBruno(wsdlFile, outputFile) { try { // Read the WSDL file const wsdlContent = await readFile(wsdlFile, 'utf8'); // Convert to Bruno collection const brunoCollection = await wsdlToBruno(wsdlContent); // Write the output await writeFile(outputFile, JSON.stringify(brunoCollection, null, 2)); console.log('WSDL conversion successful!'); } catch (error) { console.error('Error during WSDL conversion:', error.message); } } // Convert WSDL to Bruno convertWsdlToBruno('path/to/service.wsdl', 'path/to/bruno-collection.json'); ``` -------------------------------- ### res.getResponseTime() Source: https://github.com/usebruno/bruno-docs/blob/main/testing/script/javascript-reference.mdx Get the response time in milliseconds. This method is available in post-request and test scripts. ```APIDOC ### `res.getResponseTime()` Get the response time in milliseconds. ```javascript const time = res.getResponseTime(); console.log(time); // 150 ``` ``` -------------------------------- ### Testing Response Body Source: https://github.com/usebruno/bruno-docs/blob/main/testing/tests/introduction.mdx Examples of testing the content and structure of the API response body. ```javascript test("should return user data", function () { const body = res.getBody(); expect(body).to.have.property("id"); expect(body.name).to.equal("John Doe"); expect(body.email).to.contain("@example.com"); }); test("should return array of users", function () { const users = res.getBody(); expect(users).to.be.an("array"); expect(users).to.have.lengthOf(3); expect(users[0]).to.have.property("id"); }); ``` -------------------------------- ### Run Bruno Collection with Options Source: https://github.com/usebruno/bruno-docs/blob/main/bru-cli/commandOptions.mdx Use this command structure to run your Bruno collections with various command-line options. ```bash bru run [options] ``` -------------------------------- ### Testing Status Codes Source: https://github.com/usebruno/bruno-docs/blob/main/testing/tests/introduction.mdx Examples of testing HTTP status codes in API responses. ```javascript test("should return success", function () { expect(res.getStatus()).to.equal(200); }); test("should not return server error", function () { expect(res.getStatus()).to.not.equal(500); }); ```