How do we use string replacements and variables in the tests? I suspect this is common and I simply do not know where to look. Example test:
$I = new ApiTester($scenario);
$I->wantTo('Get Stuff');
$I->amHttpAuthenticated('myuser', 'mypass');
$I->haveHttpHeader('Content-Type', 'application/json');
$I->haveHttpHeader('Custom-Header', 'friendlycorp');
$I->sendGet('/a/path/that/contains/variables');
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK);
Each REST API location being tested uses different values, and also the URL changes depending on the service being tested. So, perhaps something like:
$I->amHttpAuthenticated('{USERNAME}', '{PASSWORD}');
$I->sendGet('/a/path/{SERVICE_ID}/and/{SOMETHING_ELSE}/and/such');
$I->haveHttpHeader('Custom-Header', '{SERVICE_ID}');
I'm hopeful that a configuration file could then define the likes of {SERVICE_ID} and {FUNCTION} depending on the REST API service location I'm testing, along with other variables. For example:
FriendlyCorp:
SERVICE_ID: friendlycorp
SOMETHING_ELSE: foo
USERNAME: myuser
PASSWORD: mypass
OpenExample:
SERVICE_ID: openexample
SOMETHING_ELSE: bar
USERNAME: myuser2
PASSWORD: mypass2
Then when executing codeception I'd choose to run tests against FriendlyCorp or OpenExample and said values would be used within the tests.