Added test case
This commit is contained in:
parent
e2cf8c696a
commit
51d1a38f0f
3 changed files with 16 additions and 2 deletions
2
.env
2
.env
|
@ -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
|
|
@ -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)) {
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue