<commit_before><?php

$I = new FunctionalTester($scenario);
$I->wantTo('test the user REST API endpoints');

$I->amGoingTo('ensure list users is not found without being authenticated');
$I->sendHEAD('users');
$I->seeResponseCodeIs(404);

$I->amGoingTo('ensure I cannot fetch my own information while not authenticated');
$I->sendGET('users/1');
$I->seeResponseCodeIs(401);

$I->amGoingTo('ensure I cannot view someone else');
$I->amHttpAuthenticated('admin', 'admin');
//$I->haveHttpHeader('Authorization', 'Basic '.base64_encode('admin:admin'));
$I->sendGET('users/2');
$I->seeResponseCodeIs(403);

$I->wantTo('ensure remaining actions are not available');

$I->amGoingTo('ensure list users is not found');
$I->sendHEAD('users');
$I->seeResponseCodeIs(404);
$I->sendGET('users');
$I->seeResponseCodeIs(404);

$I->amGoingTo('ensure create user is not found');
$I->sendPOST('users');
$I->seeResponseCodeIs(404);

$I->amGoingTo('ensure delete user is not found');
$I->sendDELETE('users/1');
$I->seeResponseCodeIs(404);

$I->amGoingTo('ensure options is not found');
$I->sendOPTIONS('users');
$I->seeResponseCodeIs(404);
$I->sendOPTIONS('users/1');
$I->seeResponseCodeIs(404);<commit_msg>test forbidden and unauthorised endpoints<commit_after><?php

$I = new FunctionalTester($scenario);
$I->wantTo('test unauthorised and forbidden user REST API endpoints');

$userFixtures = $I->getFixture('user');
$user = $userFixtures['admin'];
$userPassword = '<PASSWORD>';

$I->amGoingTo('ensure I cannot search for users');
$I->sendGET('users/search/'.$user['id']);
$I->seeResponseCodeIs(401);

$I->amGoingTo('ensure I cannot list any user');
$I->sendHEAD('users/'.$user['id']);
$I->seeResponseCodeIs(401);

$I->amGoingTo('ensure I cannot update any user');
$I->sendPUT('users/'.$user['id']);
$I->seeResponseCodeIs(401);

$I->wantTo('ensure the disabled actions are not usable');

$I->amGoingTo('ensure list users is not allowed');
$I->amHttpAuthenticated($user['username'], $userPassword);
$I->sendHEAD('users');
$I->seeResponseCodeIs(405);
$I->sendGET('users');
$I->seeResponseCodeIs(405);

$I->amGoingTo('ensure create user is not allowed');
$I->sendPOST('users');
$I->seeResponseCodeIs(405);

$I->amGoingTo('ensure deleting my own user is not allowed');
$I->sendDELETE('users/'.$user['id']);
$I->seeResponseCodeIs(405);

$I->amGoingTo('ensure delete user is not allowed');
$I->sendDELETE('users/'.($user['id']+1));
$I->seeResponseCodeIs(405);
{'fraction_non_alphanumeric': 0.21167283189478012, 'fraction_numerical': 0.02383888203863543, 'mean_word_length': 7.850909090909091, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5011322', 'n_tokens_mistral': 883, 'n_tokens_neox': 827, 'n_words': 182}