PROYECTO CON API DE TRELLO:

https://developer.atlassian.com/cloud/trello/guides/rest-api/api-introduction/

https://developer.atlassian.com/cloud/trello/rest/api-group-boards/

1. INTRODUCCIÓN al API

Qué es una URL:

Las direcciones Web o «URLs» (Uniform Resource Locator) son la base de Internet y una forma sencilla de identificar y encontrar cualquier cosa que buscamos en la red como páginas web, fotos y videos.

URL es la abreviación de Dirección Web. El formato de una URL esta compuesto por varias partes: Protocolo, Dominio, Extensión, Recurso y Parámetros.

Encontramos URLs en el navegador web del ordenador y del teléfono:

Estructura de una URL o Dirección Web

Una dirección web está compuesta por varias partes que en su conjunto sirven para identificar y localizar cada página web, imágen o vídeo de Internet.

En este esquema vemos todas las partes de una URL:

Vamos a ver cada elemento, empezando por la izquierda:

En la parte central del esquema vemos la extensión del dominio, el famoso .com, o .es :

Mirando a la parte izquierda de la extensión (del .com)

La parte izquierda de la extensión sirve para localizar el servidor web que alberga el contenido que queremos ver.

A la derecha de la extensión

La zona derecha de la extensión sirve para localizar la página web, la imagen o el vídeo perteneciente al dominio. Está organizado del mismo modo que los ficheros del ordenador, es decir en directorios y ficheros.

2. INTRODUCCIÓN a POSTMAN (INSTALACIÓN)

https://youtu.be/_uXdUA7g4mM

 

2. AUTHORIZATION - SETUP DEL SUT

PRECONDICIONES PARA INICIAR:
Aquí se encuentra toda la Documentación API de Trello para Postman:

Authentication and Authorization - API KEY

Trello uses a delegated authentication and authorization flow so that your application never has to deal with storing or handling usernames or passwords. Instead, your application passes control to Trello (identifying itself via the API key) and once Trello has allowed the user to choose an account and sign in, Trello will hand the user and control back to your application, along with an API Token.

To get started, you’ll need an API key. You can get your API key by logging into Trello and visiting https://trello.com/app-key. Be sure to read and agree to Trello Developer Terms of Service. Your API key will be clearly labeled at the top of that page.

Your API key should be a 32 character string comprised of random alphanumeric characters. Because of the way the authorization flow works, the API key is intended to be publicly accessible. An API key by itself doesn't grant access to a user's Trello data. However, because API tokens grant access to the user's data, they should be kept secret.

For the purposes of this walkthrough, we'll have you generate a token for yourself. On the same page where you found your API key (https://trello.com/app-key), click the hyperlinked "Token" under the API key. You should be prompted with the following screen:

 

Your users will always see this screen when granting your application access. The permissions, duration of access, and application name displayed are all configured via the URL parameters. More on that at Authorization. But we'll leave everything as is, and click "Allow".

Once you click Allow you'll grant your own app (identified via your API key) access to your account and be redirected to a page that contains the API token.

This token, along with your API key, can be used to read and write for your entire Trello account. Tokens should be kept secret!

3. HTTP REQUESTS

4. VARIABLES DE SCOPES - usando esta Sintaxis: “{{}}”

Las Variables tienen algo llamado “SCOPES”
Son los siguientes: (se mostrarán con un ejemplo de ESQUEMA DE JERARQUÍA:

Cómo se sobreescriben las mismas variables?
(por sobreescribirse, no quiere decir que la otra se borra, sino que es el Var que se utilizará)
Es por jerarquía.
En el ejemplo arriba: aunque Var Global se vea así más grande englobando todos, realmente la variable más profunda es la más poderosa, y es la que sobreescribe su antecesora.
Ejemplo:
Data → Environment → Collection → Global
(Esto solo ocurre cuando la variable se repite, se utiliza el SCOPE más profundo que se quiere usar en el Request.

5. PARAMETERS (Key-Valor)

note

COMPONENTES DE POSTMAN PARA PRUEBAS API

COMPONENTES DE POSTMAN PARA PRUEBAS API

EQUIVALENCIAS DE INCIDENCIAS QA
con el WORKFLOW de API Testing (con Postman)

 

note

SCRIPTS (AUTOMATION TESTING)

SCRIPTS (AUTOMATION TESTING)

https://learning.postman.com/docs/writing-scripts/test-scripts/

1. SINTAXIS DE LOS SCRIPTS DE PRUEBA:

2. SCRIPTS para PARAMETERS:

2. PRE-REQUEST SCRIPS

Para cada Request en una Collection, los Scripts se ejecutarán en el siguiente orden:

  1. Un Script de Pre-Request asociado a una Collection(TS), correrá PRIMERO cada Request en la Collection.

  2. Un Script de Pre-Request asociado a una Carpeta (TC), correrá PRIMERO cada Request en la Carpeta.

  3. Un Script de Test asociado a una Collection(TS), correrá DESPUÉS cada Request en la Collection.

  4. Un Script de Test asociado a una Carpeta (TC), correrá DESPUÉS cada Request en la Carpeta.

 

3. ASSERTIONS SCRIPTS

ASSERTIONS SCRIPTS en ARRAYS

SCRIPT PODEROSO PARA ENCONTRAR CUALQUIER PROPIEDAD!
Usando el Chai Assertion: “.find(Objeto => Objeto.atributo === “valor”)”

Ejemplo:

Donde “i” es una auto-variable que está refiriéndose a TODA LA ARRAY como un “item”, y que a su vez está diciendo que la llave (atributo) debe ser exactamente igual al valor (valor de la propiedad). Y lo que hará es BUSCAR TODOS LOS MISMOS ATRIBUTOS pero se detendrá cuando encuentre el valor declarado.

PLUS: SCRIPTS CON CARACTERES ESPECIALES

5. ASSERTIONS SCRIPTS para HEADERS y COOKIES

 

MÁS EJEMPLOS DE TEST SCRIPTING:

https://learning.postman.com/docs/writing-scripts/script-references/test-examples/

Assertion deep equality error

You may encounter the AssertionError: expected <value> to deeply equal '<value>'. For example, this would arise with the following code:

pm.expect(1).to.eql("1");

This happens because the test is comparing a number to a string value. The test will only return true if both the type and value are equal.

Asserting the current environment

Check the active (currently selected) environment in Postman:

pm.test("Check the active environment", () => {
  pm.expect(pm.environment.name).to.eql("Production");
});

JSON not defined error

You may encounter the ReferenceError: jsonData is not defined issue. This typically happens when you are attempting to reference a JSON object that hasn't been declared or is outside the scope of your test code.

pm.test("Test 1", () => {
  const jsonData = pm.response.json();
  pm.expect(jsonData.name).to.eql("John");
});

pm.test("Test 2", () => {
  pm.expect(jsonData.age).to.eql(29); // jsonData is not defined
});

Make sure that any code setting your response data to a variable is accessible to all test code, for example in this case moving const jsonData = pm.response.json(); before the first pm.test would make it available to both test functions.

Asserting a value type

Test the type of any part of the response:

/* response has this structure:
{
  "name": "Jane",
  "age": 29,
  "hobbies": [
    "skating",
    "painting"
  ],
  "email": null
}
*/
const jsonData = pm.response.json();
pm.test("Test data type of the response", () => {
  pm.expect(jsonData).to.be.an("object");
  pm.expect(jsonData.name).to.be.a("string");
  pm.expect(jsonData.age).to.be.a("number");
  pm.expect(jsonData.hobbies).to.be.an("array");
  pm.expect(jsonData.website).to.be.undefined;
  pm.expect(jsonData.email).to.be.null;
});

Asserting array properties

Check if an array is empty, and if it contains particular items:

/*
response has this structure:
{
  "errors": [],
  "areas": [ "goods", "services" ],
  "settings": [
    {
      "type": "notification",
      "detail": [ "email", "sms" ]
    },
    {
      "type": "visual",
      "detail": [ "light", "large" ]
    }
  ]
}
*/

const jsonData = pm.response.json();
pm.test("Test array properties", () => {
    //errors array is empty
  pm.expect(jsonData.errors).to.be.empty;
    //areas includes "goods"
  pm.expect(jsonData.areas).to.include("goods");
    //get the notification settings object
  const notificationSettings = jsonData.settings.find
      (m => m.type === "notification");
  pm.expect(notificationSettings)
    .to.be.an("object", "Could not find the setting");
    //detail array should include "sms"
  pm.expect(notificationSettings.detail).to.include("sms");
    //detail array should include all listed
  pm.expect(notificationSettings.detail)
    .to.have.members(["email", "sms"]);
});

Asserting object properties

Assert that an object contains keys or properties:

pm.expect({a: 1, b: 2}).to.have.all.keys('a', 'b');
pm.expect({a: 1, b: 2}).to.have.any.keys('a', 'b');
pm.expect({a: 1, b: 2}).to.not.have.any.keys('c', 'd');
pm.expect({a: 1}).to.have.property('a');
pm.expect({a: 1, b: 2}).to.be.an('object')
  .that.has.all.keys('a', 'b');

Target can be an object, set, array or map. If .keys is run without .all or .any, the expression defaults to .all. As .keys behavior varies based on the target type, it's recommended to check the type before using .keys with .a.

Asserting that an object is contained

Check that an object is part of a parent object:

/*
response has the following structure:
{
  "id": "d8893057-3e91-4cdd-a36f-a0af460b6373",
  "created": true,
  "errors": []
}
*/

pm.test("Object is contained", () => {
  const expectedObject = {
    "created": true,
    "errors": []
  };
  pm.expect(pm.response.json()).to.deep.include(expectedObject);
});

Using .deep causes all .equal, .include, .members, .keys, and .property assertions that follow in the chain to use deep equality (loose equality) instead of strict (===) equality. While the .eql also compares loosely, .deep.equal causes deep equality comparisons to also be used for any other assertions that follow in the chain, while .eql doesn't.

 

AUTOMATION API TESTING🚀 CON COLLECTIONS

2022-05-03 21-39-14.mp4

((EL TEMARIO SERÁ SUBIDO LUEGO DEL JUEVES 5 DE MAYO))