1
0
Fork 0
mirror of synced 2024-06-13 16:24:47 +12:00

Added test case

This commit is contained in:
Khushboo Verma 2024-01-24 18:24:48 +05:30
parent e2cf8c696a
commit 51d1a38f0f
3 changed files with 16 additions and 2 deletions

2
.env
View file

@ -103,4 +103,4 @@ _APP_ASSISTANT_OPENAI_API_KEY=
_APP_MESSAGE_SMS_TEST_DSN=
_APP_MESSAGE_EMAIL_TEST_DSN=
_APP_MESSAGE_PUSH_TEST_DSN=
_APP_RESTRICTED_COUNTRIES=
_APP_RESTRICTED_COUNTRIES=AQ

View file

@ -601,7 +601,7 @@ App::init()
->action(function (Request $request, Reader $geodb) {
if (!empty(app::getEnv('_APP_RESTRICTED_COUNTRIES', ''))) {
$countries = explode(',', App::getEnv('_APP_RESTRICTED_COUNTRIES', ''));
$record = $geodb->get($request->getHeader('x-forwarded-for'));
$record = $geodb->get($request->getIP());
$country = $record['country']['iso_code'];
$countryName = $record['country']['names']['en'];
if (in_array($country, $countries)) {

View file

@ -43,6 +43,20 @@ trait AccountBase
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-forwarded-for' => '103.152.127.250'
]), [
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
]);
$this->assertEquals(401, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',