Skip to content

Instantly share code, notes, and snippets.

@vojtech-cerveny
Created October 18, 2025 16:48
Show Gist options
  • Save vojtech-cerveny/671545dcc77a8c5710f98219ba7fd5f4 to your computer and use it in GitHub Desktop.
Save vojtech-cerveny/671545dcc77a8c5710f98219ba7fd5f4 to your computer and use it in GitHub Desktop.
Bootcamp examples

POST /user/create - happy path

endpoint: https://ostrava.czechibank.ostrava.digital/api/v1/user

{
  "email": "[email protected]",
  "name": "Papagaj Pepa 🦜",
  "password": "password123456"
}

POST /user/create - random functions

endpoint: https://ostrava.czechibank.ostrava.digital/api/v1/user

{
  "email": "{{$randomEmail}}",
  "name": "{{$randomFullName}}",
  "password": "{{$randomPassword}}"
}

Links: Postman documentation - variable list

TESTS (Validations)

Links

  1. https://learning.postman.com/docs/tests-and-scripts/write-scripts/test-scripts/

Example for checking status code - I am expecting, that response has status code 200

pm.test("should have correct status", function () {
  pm.response.to.have.status(200);
});

Example - checking payload - checking property success if it is true

pm.test("should return success response", function () {
   var jsonData = pm.response.json();
   pm.expect(jsonData.success).to.eql(true);
});

Example - checking payload - if the schema is correct

pm.test("should return user data", function(){
   var jsonData = pm.response.json();
   pm.expect(jsonData.data.user).to.have.property("name"); // if data.user has property `name`
   pm.expect(jsonData.data.user).to.have.property("email");  // if data.user has property `email`
   pm.expect(jsonData.data.user).to.not.have.property("password"); // if data.user has property password

   pm.expect(jsonData.data.user.name).to.eql("Vojta 🦊 Cerveny"); // if property `data.user.name` has value "Vojta 🦊 Cerveny"
   pm.expect(jsonData.data.user.email).to.eql("[email protected]"); // if property `data.user.email` has value "[email protected]" 
})

// Same, buf without comments
pm.test("should return user data", function(){
   var jsonData = pm.response.json();
   pm.expect(jsonData.data.user).to.have.property("name");
   pm.expect(jsonData.data.user).to.have.property("email");
   pm.expect(jsonData.data.user).to.not.have.property("password");

   pm.expect(jsonData.data.user.name).to.eql("Vojta 🦊 Cerveny");
   pm.expect(jsonData.data.user.email).to.eql("[email protected]");
})

Transactions - scripts

// save informations into variable (proměnná)
const body = pm.response.json();
const msg = body?.data?.message;

pm.test("HTTP status is OK (201)", () => {
  pm.response.to.have.status(201);
});

pm.test("response time should be less than 500ms", () => {
    pm.expect(pm.response.responseTime).to.be.below(500);
})

pm.test("amount is a positive specific number", () => {
  pm.expect(msg.amount).to.be.a("number")
  pm.expect(msg.amount).to.be.eql(44.4);
});

pm.test("currency is exactly CZECHITOKEN", () => {
  pm.expect(msg.currency).to.eql("CZECHITOKEN");
});

pm.test("from.number and to.number have expected account numbers", () => {
  pm.expect(msg.from.number).to.eql("968558900169/5555")
  pm.expect(msg.to.number).to.eq("555555555555/5555")
});

FLOW CREATE USER -> CREATE TRANSACTION

// FIRST REQUEST - create new user 
// endpoint: https://ostrava.czechibank.ostrava.digital/api/v1/user/create

// body:
{
  "name": "💔 A TY a Tvůj DONATE JSTE KDE? 💔 🫵",
  "email": "{{$randomEmail}}",
  "password": "securepassword123"
}

// post request;
const response = pm.response.json();
pm.collectionVariables.set("apiKeyFromResponse", response.apiKey);


// SECOND REQUEST - check number of your bank account
// endpoint: https://ostrava.czechibank.ostrava.digital/api/v1/bank-account/
// API-key: set to {{apiKeyFromResponse}}

// post request:
const response = pm.response.json();
pm.collectionVariables.set("bankAccountFromResponse", response.data.bankAccounts[0].number); 

// THIRD REQUEST - send czechitokens to some bank account
// Endpoint https://ostrava.czechibank.ostrava.digital/api/v1/transactions/create
// API-key: set to {{apiKeyFromResponse}}
// payload: 
{
    "amount": 1,
    "fromBankNumber": "{{bankAccountFromResponse}}",
    "toBankNumber":   "000000000001/5555"
}

YOUR FLOW 1

// HELP 
// What info do you need? Do you need some test?
// This post-script will help you: 
const response = pm.response.json();
// in variable firstBankAccount is all informations about your first bank accout. 
// Now you need to find way, how to check if the it has 100000 CZECHITOKENs
const firstBankAccount = response.data.bankAccounts[0];

// Check previous tests how to do that. 
pm.test("template for your test.", () => {
  pm.expect().to.eql();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment