ci(postman): add users collection (#4897)

This commit is contained in:
Apoorv Dixit
2024-06-10 18:17:53 +05:30
committed by GitHub
parent adb9b11f69
commit a2b17cbc96
42 changed files with 1181 additions and 10 deletions

1
Cargo.lock generated
View File

@ -7021,6 +7021,7 @@ dependencies = [
name = "test_utils"
version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
"base64 0.22.0",
"clap",

View File

@ -14,6 +14,7 @@ payouts = []
[dependencies]
async-trait = "0.1.79"
anyhow = "1.0.81"
base64 = "0.22.0"
clap = { version = "4.4.18", default-features = false, features = ["std", "derive", "help", "usage"] }
rand = "0.8.5"

View File

@ -76,6 +76,7 @@ pub struct ConnectorAuthentication {
pub zen: Option<HeaderKey>,
pub zsl: Option<BodyKey>,
pub automation_configs: Option<AutomationConfigs>,
pub users: Option<UsersConfigs>,
}
impl Default for ConnectorAuthentication {
@ -339,3 +340,12 @@ pub enum ConnectorAuthType {
#[default]
NoKey,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UsersConfigs {
pub user_email: String,
pub user_password: String,
pub wrong_password: String,
pub user_base_email_for_signup: String,
pub user_domain_for_signup: String,
}

View File

@ -1,9 +1,10 @@
use std::process::{exit, Command};
use anyhow::Result;
use test_utils::newman_runner;
fn main() {
let mut runner = newman_runner::generate_newman_command();
fn main() -> Result<()> {
let mut runner = newman_runner::generate_runner()?;
// Execute the newman command
let output = runner.newman_command.spawn();

View File

@ -6,14 +6,23 @@ use std::{
process::{exit, Command},
};
use clap::{arg, command, Parser};
use anyhow::{Context, Result};
use clap::{arg, command, Parser, ValueEnum};
use masking::PeekInterface;
use regex::Regex;
use crate::connector_auth::{ConnectorAuthType, ConnectorAuthenticationMap};
use crate::connector_auth::{
ConnectorAuthType, ConnectorAuthentication, ConnectorAuthenticationMap,
};
#[derive(ValueEnum, Clone, Copy)]
pub enum Module {
Connector,
Users,
}
#[derive(Parser)]
#[command(version, about = "Postman collection runner using newman!", long_about = None)]
struct Args {
pub struct Args {
/// Admin API Key of the environment
#[arg(short, long)]
admin_api_key: String,
@ -22,7 +31,10 @@ struct Args {
base_url: String,
/// Name of the connector
#[arg(short, long)]
connector_name: String,
connector_name: Option<String>,
/// Name of the module
#[arg(short, long)]
module_name: Option<Module>,
/// Custom headers
#[arg(short = 'H', long = "header")]
custom_headers: Option<Vec<String>>,
@ -38,6 +50,13 @@ struct Args {
verbose: bool,
}
impl Args {
/// Getter for the `module_name` field
pub fn get_module_name(&self) -> Option<Module> {
self.module_name
}
}
pub struct ReturnArgs {
pub newman_command: Command,
pub modified_file_paths: Vec<Option<String>>,
@ -82,10 +101,93 @@ where
Ok(())
}
pub fn generate_newman_command() -> ReturnArgs {
// This function gives runner for connector or a module
pub fn generate_runner() -> Result<ReturnArgs> {
let args = Args::parse();
let connector_name = args.connector_name;
match args.get_module_name() {
Some(Module::Users) => generate_newman_command_for_users(),
Some(Module::Connector) => generate_newman_command_for_connector(),
// Running connector tests when no module is passed to keep the previous test behavior same
None => generate_newman_command_for_connector(),
}
}
pub fn generate_newman_command_for_users() -> Result<ReturnArgs> {
let args = Args::parse();
let base_url = args.base_url;
let admin_api_key = args.admin_api_key;
let path = env::var("CONNECTOR_AUTH_FILE_PATH")
.with_context(|| "connector authentication file path not set")?;
let authentication: ConnectorAuthentication = toml::from_str(
&fs::read_to_string(path)
.with_context(|| "connector authentication config file not found")?,
)
.with_context(|| "connector authentication file path not set")?;
let users_configs = authentication
.users
.with_context(|| "user configs not found in authentication file")?;
let collection_path = get_collection_path("users");
let mut newman_command = Command::new("newman");
newman_command.args(["run", &collection_path]);
newman_command.args(["--env-var", &format!("admin_api_key={admin_api_key}")]);
newman_command.args(["--env-var", &format!("baseUrl={base_url}")]);
newman_command.args([
"--env-var",
&format!("user_email={}", users_configs.user_email),
]);
newman_command.args([
"--env-var",
&format!(
"user_base_email_for_signup={}",
users_configs.user_base_email_for_signup
),
]);
newman_command.args([
"--env-var",
&format!(
"user_domain_for_signup={}",
users_configs.user_domain_for_signup
),
]);
newman_command.args([
"--env-var",
&format!("user_password={}", users_configs.user_password),
]);
newman_command.args([
"--env-var",
&format!("wrong_password={}", users_configs.wrong_password),
]);
newman_command.args([
"--delay-request",
format!("{}", &args.delay_request).as_str(),
]);
newman_command.arg("--color").arg("on");
if args.verbose {
newman_command.arg("--verbose");
}
Ok(ReturnArgs {
newman_command,
modified_file_paths: vec![],
collection_path,
})
}
pub fn generate_newman_command_for_connector() -> Result<ReturnArgs> {
let args = Args::parse();
let connector_name = args
.connector_name
.with_context(|| "invalid parameters: connector/module name not found in arguments")?;
let base_url = args.base_url;
let admin_api_key = args.admin_api_key;
@ -216,11 +318,11 @@ pub fn generate_newman_command() -> ReturnArgs {
newman_command.arg("--verbose");
}
ReturnArgs {
Ok(ReturnArgs {
newman_command,
modified_file_paths: vec![modified_collection_file_paths, custom_header_exist],
collection_path,
}
})
}
pub fn check_for_custom_headers(headers: Option<Vec<String>>, path: &str) -> Option<String> {

View File

@ -0,0 +1,6 @@
{
"eventOrder": [
"event.prerequest.js",
"event.test.js"
]
}

View File

@ -0,0 +1,9 @@
{
"info": {
"_postman_id": "b5b40c9a-7e58-42c7-8b89-0adb208c45c9",
"name": "users",
"description": "## Get started\n\nJuspay Router provides a collection of APIs that enable you to process and manage payments. Our APIs accept and return JSON in the HTTP body, and return standard HTTP response codes. \nYou can consume the APIs directly using your favorite HTTP/REST library. \nWe have a testing environment referred to \"sandbox\", which you can setup to test API calls without affecting production data.\n\n### Base URLs\n\nUse the following base URLs when making requests to the APIs:\n\n| Environment | Base URL |\n| --- | --- |\n| Sandbox | [https://sandbox.hyperswitch.io](https://sandbox.hyperswitch.io) |\n| Production | [https://router.juspay.io](https://router.juspay.io) |\n\n# Authentication\n\nWhen you sign up for an account, you are given a secret key (also referred as api-key). You may authenticate all API requests with Juspay server by providing the appropriate key in the request Authorization header. \nNever share your secret api keys. Keep them guarded and secure.\n\nContact Support: \nName: Juspay Support \nEmail: [support@juspay.in](mailto:support@juspay.in)",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "26710321"
}
}

View File

@ -0,0 +1,6 @@
{
"childrenOrder": [
"Health check",
"Flow Testcases"
]
}

View File

@ -0,0 +1,126 @@
{
"variable": [
{
"key": "baseUrl",
"value": "",
"type": "string"
},
{
"key": "admin_api_key",
"value": "",
"type": "string"
},
{
"key": "api_key",
"value": "",
"type": "string"
},
{
"key": "merchant_id",
"value": ""
},
{
"key": "payment_id",
"value": ""
},
{
"key": "customer_id",
"value": ""
},
{
"key": "mandate_id",
"value": ""
},
{
"key": "payment_method_id",
"value": ""
},
{
"key": "refund_id",
"value": ""
},
{
"key": "merchant_connector_id",
"value": ""
},
{
"key": "client_secret",
"value": "",
"type": "string"
},
{
"key": "connector_api_key",
"value": "",
"type": "string"
},
{
"key": "publishable_key",
"value": "",
"type": "string"
},
{
"key": "api_key_id",
"value": "",
"type": "string"
},
{
"key": "payment_token",
"value": ""
},
{
"key": "gateway_merchant_id",
"value": "",
"type": "string"
},
{
"key": "certificate",
"value": "",
"type": "string"
},
{
"key": "certificate_keys",
"value": "",
"type": "string"
},
{
"key": "connector_api_secret",
"value": "",
"type": "string"
},
{
"key": "connector_key1",
"value": "",
"type": "string"
},
{
"key": "connector_key2",
"value": "",
"type": "string"
},
{
"key": "user_email",
"value": "",
"type": "string"
},
{
"key": "user_password",
"value": "",
"type": "string"
},
{
"key": "wrong_password",
"value": "",
"type": "string"
},
{
"key": "user_base_email_for_signup",
"value": "",
"type": "string"
},
{
"key": "user_domain_for_signup",
"value": "",
"type": "string"
}
]
}

View File

@ -0,0 +1,6 @@
{
"childrenOrder": [
"Sign Up",
"Sign In"
]
}

View File

@ -0,0 +1,8 @@
{
"childrenOrder": [
"Signin",
"Signin Wrong",
"Signin Token Only",
"Signin Token Only Wrong"
]
}

View File

@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}

View File

@ -0,0 +1,16 @@
// Validate status 4xx
pm.test("[POST]::/user/v2/signin?token_only=true - Status code is 401", function () {
pm.response.to.have.status(401);
});
// Validate if response header has matching content-type
pm.test("[POST]::user/v2/signin?token_only=true - Content-Type is application/json", function () {
pm.expect(pm.response.headers.get("Content-Type")).to.include(
"application/json",
);
});
// Validate if response has JSON Body
pm.test("[POST]::user/v2/signin?token_only=true - Response has JSON Body", function () {
pm.response.to.have.jsonBody();
});

View File

@ -0,0 +1,37 @@
{
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Cookie",
"value": "Cookie_1=value"
}
],
"body": {
"mode": "raw",
"raw_json_formatted": {
"email": "{{user_email}}",
"password": "{{wrong_password}}"
}
},
"url": {
"raw": "{{baseUrl}}/user/v2/signin?token_only=true",
"host": [
"{{baseUrl}}"
],
"path": [
"user",
"v2",
"signin"
],
"query": [
{
"key": "token_only",
"value": "true"
}
]
}
}

View File

@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}

View File

@ -0,0 +1,23 @@
// Validate status 2xx
pm.test("[POST]::user/v2/signin?token_only=true - Status code is 2xx", function () {
pm.response.to.be.success;
});
// Validate if response header has matching content-type
pm.test("[POST]::user/v2/signin?token_only=true - Content-Type is application/json", function () {
pm.expect(pm.response.headers.get("Content-Type")).to.include(
"application/json",
);
});
// Validate if response has JSON Body
pm.test("[POST]::user/v2/signin?token_only=true - Response has JSON Body", function () {
pm.response.to.have.jsonBody();
});
// Validate specific JSON response content
pm.test("[POST]::user/v2/signin?token_only=true - Response contains token", function () {
var jsonData = pm.response.json();
pm.expect(jsonData).to.have.property("token");
pm.expect(jsonData.token).to.be.a("string").and.to.not.be.empty;
});

View File

@ -0,0 +1,37 @@
{
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Cookie",
"value": "Cookie_1=value"
}
],
"body": {
"mode": "raw",
"raw_json_formatted": {
"email": "{{user_email}}",
"password": "{{user_password}}"
}
},
"url": {
"raw": "{{baseUrl}}/user/v2/signin?token_only=true",
"host": [
"{{baseUrl}}"
],
"path": [
"user",
"v2",
"signin"
],
"query": [
{
"key": "token_only",
"value": "true"
}
]
}
}

View File

@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}

View File

@ -0,0 +1,16 @@
// Validate status code is 4xx Bad Request
pm.test("[POST]::/user/v2/signin - Status code is 401", function () {
pm.response.to.have.status(401);
});
// Validate if response header has matching content-type
pm.test("[POST]::/user/v2/signin - Content-Type is application/json", function () {
pm.expect(pm.response.headers.get("Content-Type")).to.include(
"application/json",
);
});
// Validate if response has JSON Body
pm.test("[POST]::/user/v2/signin - Response has JSON Body", function () {
pm.response.to.have.jsonBody();
});

View File

@ -0,0 +1,31 @@
{
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Cookie",
"value": "Cookie_1=value"
}
],
"body": {
"mode": "raw",
"raw_json_formatted": {
"email": "{{user_email}}",
"password": "{{wrong_password}}"
}
},
"url": {
"raw": "{{baseUrl}}/user/v2/signin",
"host": [
"{{baseUrl}}"
],
"path": [
"user",
"v2",
"signin"
]
}
}

View File

@ -0,0 +1,6 @@
{
"eventOrder": [
"event.test.js",
"event.prerequest.js"
]
}

View File

@ -0,0 +1,23 @@
// Validate status 2xx
pm.test("[POST]::/user/v2/signin - Status code is 2xx", function () {
pm.response.to.be.success;
});
// Validate if response header has matching content-type
pm.test("[POST]::/user/v2/signin - Content-Type is application/json", function () {
pm.expect(pm.response.headers.get("Content-Type")).to.include(
"application/json",
);
});
// Validate if response has JSON Body
pm.test("[POST]::/user/v2/signin - Response has JSON Body", function () {
pm.response.to.have.jsonBody();
});
// Validate specific JSON response content
pm.test("[POST]::/user/v2/signin - Response contains token", function () {
var jsonData = pm.response.json();
pm.expect(jsonData).to.have.property("token");
pm.expect(jsonData.token).to.be.a("string").and.to.not.be.empty;
});

View File

@ -0,0 +1,31 @@
{
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Cookie",
"value": "Cookie_1=value"
}
],
"body": {
"mode": "raw",
"raw_json_formatted": {
"email": "{{user_email}}",
"password": "{{user_password}}"
}
},
"url": {
"raw": "{{baseUrl}}/user/v2/signin",
"host": [
"{{baseUrl}}"
],
"path": [
"user",
"v2",
"signin"
]
}
}

View File

@ -0,0 +1,5 @@
{
"childrenOrder": [
"Connect Account"
]
}

View File

@ -0,0 +1,6 @@
{
"eventOrder": [
"event.test.js",
"event.prerequest.js"
]
}

View File

@ -0,0 +1,8 @@
var baseEmail = pm.environment.get('user_base_email_for_signup');
var emailDomain = pm.environment.get("user_domain_for_signup");
// Generate a unique email address
var uniqueEmail = baseEmail + new Date().getTime() + emailDomain;
// Set the unique email address as an environment variable
pm.environment.set('unique_email', uniqueEmail);

View File

@ -0,0 +1,23 @@
// Validate status 2xx
pm.test("[POST]::/user/connect_account - Status code is 2xx", function () {
pm.response.to.be.success;
});
// Validate if response header has matching content-type
pm.test("[POST]::/user/connect_account - Content-Type is application/json", function () {
pm.expect(pm.response.headers.get("Content-Type")).to.include(
"application/json",
);
});
// Validate if response has JSON Body
pm.test("[POST]::/user/connect_account - Response has JSON Body", function () {
pm.response.to.have.jsonBody();
});
// Validate specific JSON response content
pm.test("[POST]::/user/connect_account - Response contains is_email_sent", function () {
var jsonData = pm.response.json();
pm.expect(jsonData).to.have.property("is_email_sent");
pm.expect(jsonData.is_email_sent).to.be.true;
});

View File

@ -0,0 +1,29 @@
{
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Cookie",
"value": "Cookie_1=value"
}
],
"body": {
"mode": "raw",
"raw_json_formatted": {
"email": "{{unique_email}}"
}
},
"url": {
"raw": "{{baseUrl}}/user/connect_account",
"host": [
"{{baseUrl}}"
],
"path": [
"user",
"connect_account"
]
}
}

View File

@ -0,0 +1,5 @@
{
"childrenOrder": [
"New Request"
]
}

View File

@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}

View File

@ -0,0 +1,4 @@
// Validate status 2xx
pm.test("[POST]::/health - Status code is 2xx", function () {
pm.response.to.be.success;
});

View File

@ -0,0 +1,13 @@
{
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/health",
"host": [
"{{baseUrl}}"
],
"path": [
"health"
]
}
}

View File

@ -0,0 +1,556 @@
{
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"item": [
{
"name": "Health check",
"item": [
{
"name": "New Request",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Validate status 2xx",
"pm.test(\"[POST]::/health - Status code is 2xx\", function () {",
" pm.response.to.be.success;",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/health",
"host": [
"{{baseUrl}}"
],
"path": [
"health"
]
}
},
"response": []
}
]
},
{
"name": "Flow Testcases",
"item": [
{
"name": "Sign Up",
"item": [
{
"name": "Connect Account",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Validate status 2xx",
"pm.test(\"[POST]::/user/connect_account - Status code is 2xx\", function () {",
" pm.response.to.be.success;",
"});",
"",
"// Validate if response header has matching content-type",
"pm.test(\"[POST]::/user/connect_account - Content-Type is application/json\", function () {",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",
" \"application/json\",",
" );",
"});",
"",
"// Validate if response has JSON Body",
"pm.test(\"[POST]::/user/connect_account - Response has JSON Body\", function () {",
" pm.response.to.have.jsonBody();",
"});",
"",
"// Validate specific JSON response content",
"pm.test(\"[POST]::/user/connect_account - Response contains is_email_sent\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"is_email_sent\");",
" pm.expect(jsonData.is_email_sent).to.be.true;",
"});",
""
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"exec": [
"",
"var baseEmail = pm.environment.get('user_base_email_for_signup');",
"var emailDomain = pm.environment.get(\"user_domain_for_signup\");",
"",
"// Generate a unique email address",
"var uniqueEmail = baseEmail + new Date().getTime() + emailDomain;",
"// Set the unique email address as an environment variable",
"pm.environment.set('unique_email', uniqueEmail);",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Cookie",
"value": "Cookie_1=value"
}
],
"body": {
"mode": "raw",
"raw": "{\"email\":\"{{unique_email}}\"}"
},
"url": {
"raw": "{{baseUrl}}/user/connect_account",
"host": [
"{{baseUrl}}"
],
"path": [
"user",
"connect_account"
]
}
},
"response": []
}
]
},
{
"name": "Sign In",
"item": [
{
"name": "Signin",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Validate status 2xx",
"pm.test(\"[POST]::/user/v2/signin - Status code is 2xx\", function () {",
" pm.response.to.be.success;",
"});",
"",
"// Validate if response header has matching content-type",
"pm.test(\"[POST]::/user/v2/signin - Content-Type is application/json\", function () {",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",
" \"application/json\",",
" );",
"});",
"",
"// Validate if response has JSON Body",
"pm.test(\"[POST]::/user/v2/signin - Response has JSON Body\", function () {",
" pm.response.to.have.jsonBody();",
"});",
"",
"// Validate specific JSON response content",
"pm.test(\"[POST]::/user/v2/signin - Response contains token\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"token\");",
" pm.expect(jsonData.token).to.be.a(\"string\").and.to.not.be.empty;",
"});"
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Cookie",
"value": "Cookie_1=value"
}
],
"body": {
"mode": "raw",
"raw": "{\"email\":\"{{user_email}}\",\"password\":\"{{user_password}}\"}"
},
"url": {
"raw": "{{baseUrl}}/user/v2/signin",
"host": [
"{{baseUrl}}"
],
"path": [
"user",
"v2",
"signin"
]
}
},
"response": []
},
{
"name": "Signin Wrong",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Validate status code is 4xx Bad Request",
"pm.test(\"[POST]::/user/v2/signin - Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});",
"",
"// Validate if response header has matching content-type",
"pm.test(\"[POST]::/user/v2/signin - Content-Type is application/json\", function () {",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",
" \"application/json\",",
" );",
"});",
"",
"// Validate if response has JSON Body",
"pm.test(\"[POST]::/user/v2/signin - Response has JSON Body\", function () {",
" pm.response.to.have.jsonBody();",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Cookie",
"value": "Cookie_1=value"
}
],
"body": {
"mode": "raw",
"raw": "{\"email\":\"{{user_email}}\",\"password\":\"{{wrong_password}}\"}"
},
"url": {
"raw": "{{baseUrl}}/user/v2/signin",
"host": [
"{{baseUrl}}"
],
"path": [
"user",
"v2",
"signin"
]
}
},
"response": []
},
{
"name": "Signin Token Only",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Validate status 2xx",
"pm.test(\"[POST]::user/v2/signin?token_only=true - Status code is 2xx\", function () {",
" pm.response.to.be.success;",
"});",
"",
"// Validate if response header has matching content-type",
"pm.test(\"[POST]::user/v2/signin?token_only=true - Content-Type is application/json\", function () {",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",
" \"application/json\",",
" );",
"});",
"",
"// Validate if response has JSON Body",
"pm.test(\"[POST]::user/v2/signin?token_only=true - Response has JSON Body\", function () {",
" pm.response.to.have.jsonBody();",
"});",
"",
"// Validate specific JSON response content",
"pm.test(\"[POST]::user/v2/signin?token_only=true - Response contains token\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData).to.have.property(\"token\");",
" pm.expect(jsonData.token).to.be.a(\"string\").and.to.not.be.empty;",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Cookie",
"value": "Cookie_1=value"
}
],
"body": {
"mode": "raw",
"raw": "{\"email\":\"{{user_email}}\",\"password\":\"{{user_password}}\"}"
},
"url": {
"raw": "{{baseUrl}}/user/v2/signin?token_only=true",
"host": [
"{{baseUrl}}"
],
"path": [
"user",
"v2",
"signin"
],
"query": [
{
"key": "token_only",
"value": "true"
}
]
}
},
"response": []
},
{
"name": "Signin Token Only Wrong",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Validate status 4xx",
"pm.test(\"[POST]::/user/v2/signin?token_only=true - Status code is 401\", function () {",
" pm.response.to.have.status(401);",
"});",
"",
"// Validate if response header has matching content-type",
"pm.test(\"[POST]::user/v2/signin?token_only=true - Content-Type is application/json\", function () {",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",
" \"application/json\",",
" );",
"});",
"",
"// Validate if response has JSON Body",
"pm.test(\"[POST]::user/v2/signin?token_only=true - Response has JSON Body\", function () {",
" pm.response.to.have.jsonBody();",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Cookie",
"value": "Cookie_1=value"
}
],
"body": {
"mode": "raw",
"raw": "{\"email\":\"{{user_email}}\",\"password\":\"{{wrong_password}}\"}"
},
"url": {
"raw": "{{baseUrl}}/user/v2/signin?token_only=true",
"host": [
"{{baseUrl}}"
],
"path": [
"user",
"v2",
"signin"
],
"query": [
{
"key": "token_only",
"value": "true"
}
]
}
},
"response": []
}
]
}
]
}
],
"info": {
"_postman_id": "b5b40c9a-7e58-42c7-8b89-0adb208c45c9",
"name": "users",
"description": "## Get started\n\nJuspay Router provides a collection of APIs that enable you to process and manage payments. Our APIs accept and return JSON in the HTTP body, and return standard HTTP response codes. \nYou can consume the APIs directly using your favorite HTTP/REST library. \nWe have a testing environment referred to \"sandbox\", which you can setup to test API calls without affecting production data.\n\n### Base URLs\n\nUse the following base URLs when making requests to the APIs:\n\n| Environment | Base URL |\n| --- | --- |\n| Sandbox | [https://sandbox.hyperswitch.io](https://sandbox.hyperswitch.io) |\n| Production | [https://router.juspay.io](https://router.juspay.io) |\n\n# Authentication\n\nWhen you sign up for an account, you are given a secret key (also referred as api-key). You may authenticate all API requests with Juspay server by providing the appropriate key in the request Authorization header. \nNever share your secret api keys. Keep them guarded and secure.\n\nContact Support: \nName: Juspay Support \nEmail: [support@juspay.in](mailto:support@juspay.in)",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "26710321"
},
"variable": [
{
"key": "baseUrl",
"value": "",
"type": "string"
},
{
"key": "admin_api_key",
"value": "",
"type": "string"
},
{
"key": "api_key",
"value": "",
"type": "string"
},
{
"key": "merchant_id",
"value": ""
},
{
"key": "payment_id",
"value": ""
},
{
"key": "customer_id",
"value": ""
},
{
"key": "mandate_id",
"value": ""
},
{
"key": "payment_method_id",
"value": ""
},
{
"key": "refund_id",
"value": ""
},
{
"key": "merchant_connector_id",
"value": ""
},
{
"key": "client_secret",
"value": "",
"type": "string"
},
{
"key": "connector_api_key",
"value": "",
"type": "string"
},
{
"key": "publishable_key",
"value": "",
"type": "string"
},
{
"key": "api_key_id",
"value": "",
"type": "string"
},
{
"key": "payment_token",
"value": ""
},
{
"key": "gateway_merchant_id",
"value": "",
"type": "string"
},
{
"key": "certificate",
"value": "",
"type": "string"
},
{
"key": "certificate_keys",
"value": "",
"type": "string"
},
{
"key": "connector_api_secret",
"value": "",
"type": "string"
},
{
"key": "connector_key1",
"value": "",
"type": "string"
},
{
"key": "connector_key2",
"value": "",
"type": "string"
},
{
"key": "user_email",
"value": "",
"type": "string"
},
{
"key": "user_password",
"value": "",
"type": "string"
},
{
"key": "wrong_password",
"value": "",
"type": "string"
},
{
"key": "user_base_email_for_signup",
"value": "",
"type": "string"
},
{
"key": "user_domain_for_signup",
"value": "",
"type": "string"
}
]
}