Small helper for iOS automated test

Create test cases on the fly

Helper

function runTestcase(description, teststeps) {
  try {
    UIALogger.logStart(description);
    teststeps();
    UIALogger.logPass("Testcase passed");
  } catch (exception) {
    UIALogger.logError(exception.message);
    target.logElementTree();
    UIALogger.logFail("Testcase failed");
    throw exception;
  }
}

Example

var target = UIATarget.localTarget();
var app = target.frontMostApp();
var window = app.mainWindow();

runTestcase("Press register button", function() {
  var expected = "register button";
  var register_btn = window.buttons()["Register"];
  if (!register_btn.isValid()) {
    throw new Error("not found: '" + expected + "'");
  } else {
    register_btn.tap();
  }
});

Dynamic data for JMeter

Preparation

JAVA and JMeter are already installed.

Steps

Create new “Test Plan” and add one “Thread Group” (Threads (Users)).

  • Number of Threads: 1
  • Ramp-Up Period: 1
  • Loop Count Forever: checked
meter thread group

Add to the “Thread Group” one “CSV Data Set Config” (Config Element).

  • Filename: Path to your CSV file
  • Variable Names: LOOP,HOST,PORT,URL
  • Delimiter: ,
  • Allow quoted data: true
  • Recycle on EOF: false
  • Stop thread on EOF: true
jmeter csv data set config

Add to the “Thread Group” one “HTTP Request Defaults” (Config Element).

  • Server Name or IP: ${HOST}
  • Port Number: ${PORT}
jmeter http request defaults

Add to the “Thread Group” one “Loop Controller” (Logic Controller).

  • Loop Count: ${LOOP}
  • Forever: not checked
jmeter loop controller

Add to the “Loop Controller” one “HTTP Request” (Sampler).

  • Method: GET
  • Path: ${URL}
  • Follow Redirects: checked
  • Use KeepAlive: checked
jmeter http request

Add to the “Thread Group” one “View Results Tree” (Listener).

meter view result tree

Rename the “HTTP Request” into “${HOST}:${PORT}${URL}”.

jmeter http request extension

Create the CSV file with some comma separated values (LOOP,HOST,PORT,URL).

jmeter csv

Run

Save the test plan as JMX file and run the test plan.

jmeter result

Scan for available http methods

This small script helps penetration testers to find all available http methods for a specific host.

#!/usr/bin/env bash

# define shell options
set -e
set -u

# define magic variables
declare -r FILE_NAME=$(basename "$0")
declare -r -i SUCCESS=0
declare -r -i NO_ARGS=84
declare -r -i BAD_ARGS=85

# usage function function
fc_usage() {
  printf "Usage: %s -i <host>" "$FILE_NAME"
}

# error function function
fc_no_args() {
  printf "Error: no arguments supplied\n"
  exit "$NO_ARGS"
}

# check script arguments
if [ "$#" -eq 0 ]; then
  fc_no_args
fi

while getopts "i:" OPTION; do
  case "$OPTION" in
    i)
        HOST="$OPTARG";;
    *)
        fc_usage exit "$BAD_ARGS";;
  esac
done

# show http method function
function fc_http_method() {
  for METH in GET POST PUT TRACE CONNECT OPTIONS PROPFIND; do
    printf "%s - " "$METH"
    printf "$METH / HTTP/1.1\nHost: $HOST\n\n" | nc -w 1 $HOST 80 | grep "HTTP/1.1"
  done
}

fc_http_method
exit "$SUCCESS"