Issues (127)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

User/UI/API/Tests/Functional/RegisterUserTest.php (5 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace App\Containers\User\UI\API\Tests\Functional;
4
5
use App\Containers\User\Tests\ApiTestCase;
6
7
/**
8
 * Class RegisterUserTest.
9
 *
10
 * @group user
11
 * @group api
12
 *
13
 * @author Mahmoud Zalt <[email protected]>
14
 */
15
class RegisterUserTest extends ApiTestCase
16
{
17
18
    protected $endpoint = '[email protected]/register';
19
20
    protected $auth = false;
21
22
    protected $access = [
23
        'roles'       => '',
24
        'permissions' => '',
25
    ];
26
27
    /**
28
     * @test
29
     */
30 View Code Duplication
    public function testRegisterNewUserWithCredentials_()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        $data = [
33
            'email'    => '[email protected]',
34
            'name'     => 'Apiato',
35
            'password' => 'secretpass',
36
        ];
37
38
        // send the HTTP request
39
        $response = $this->makeCall($data);
40
41
        // assert response status is correct
42
        $response->assertStatus(200);
43
44
        $this->assertResponseContainKeyValue([
45
            'email' => $data['email'],
46
            'name'  => $data['name'],
47
        ]);
48
49
        $responseContent = $this->getResponseContentObject();
50
51
        $this->assertNotEmpty($responseContent->data);
52
53
         // assert the data is stored in the database
54
        $this->assertDatabaseHas('users', ['email' => $data['email']]);
55
    }
56
57
    /**
58
     * @test
59
     */
60
    public function testRegisterNewUserUsingGetVerb()
61
    {
62
        $data = [
63
            'email'    => '[email protected]',
64
            'name'     => 'Apiato',
65
            'password' => 'secret',
66
        ];
67
68
        // send the HTTP request
69
        $response = $this->endpoint('[email protected]/register')->makeCall($data);
70
71
        // assert response status is correct
72
        $response->assertStatus(405);
73
74
        $this->assertResponseContainKeyValue([
75
            'errors' => 'Method Not Allowed!',
76
        ]);
77
    }
78
79
    /**
80
     * @test
81
     */
82
    public function testRegisterExistingUser()
83
    {
84
        $userDetails = [
85
            'email'    => '[email protected]',
86
            'name'     => 'Apiato',
87
            'password' => 'secret',
88
        ];
89
90
        // get the logged in user (create one if no one is logged in)
91
        $this->getTestingUser($userDetails);
92
93
        $data = [
94
            'email'    => $userDetails['email'],
95
            'name'     => $userDetails['name'],
96
            'password' => $userDetails['password'],
97
        ];
98
99
        // send the HTTP request
100
        $response = $this->makeCall($data);
101
102
        // assert response status is correct
103
        $response->assertStatus(422);
104
105
        $this->assertValidationErrorContain([
106
            'email' => 'The email has already been taken.',
107
        ]);
108
    }
109
110
    /**
111
     * @test
112
     */
113 View Code Duplication
    public function testRegisterNewUserWithoutEmail()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
114
    {
115
        $data = [
116
            'name'     => 'Apiato',
117
            'password' => 'secret',
118
        ];
119
120
        // send the HTTP request
121
        $response = $this->makeCall($data);
122
123
        // assert response status is correct
124
        $response->assertStatus(422);
125
126
        // assert response contain the correct message
127
        $this->assertValidationErrorContain([
128
            'email' => 'The email field is required.',
129
        ]);
130
    }
131
132
    /**
133
     * @test
134
     */
135 View Code Duplication
    public function testRegisterNewUserWithoutName()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
136
    {
137
        $data = [
138
            'email'    => '[email protected]',
139
            'password' => 'secret',
140
        ];
141
142
        // send the HTTP request
143
        $response = $this->makeCall($data);
144
145
        // assert response status is correct
146
        $response->assertStatus(422);
147
148
        // assert response contain the correct message
149
        $this->assertValidationErrorContain([
150
            'name' => 'The name field is required.',
151
        ]);
152
    }
153
154
    /**
155
     * @test
156
     */
157 View Code Duplication
    public function testRegisterNewUserWithoutPassword()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
158
    {
159
        $data = [
160
            'email' => '[email protected]',
161
            'name'  => 'Apiato',
162
        ];
163
164
        $response = $this->makeCall($data);
165
166
        // assert response status is correct
167
        $response->assertStatus(422);
168
169
        // assert response contain the correct message
170
        $this->assertValidationErrorContain([
171
            'password' => 'The password field is required.',
172
        ]);
173
    }
174
175
    /**
176
     * @test
177
     */
178 View Code Duplication
    public function testRegisterNewUserWithInvalidEmail()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
179
    {
180
        $data = [
181
            'email'    => 'missing-at.dev',
182
            'name'     => 'Apiato',
183
            'password' => 'secret',
184
        ];
185
186
        // send the HTTP request
187
        $response = $this->makeCall($data);
188
189
        // assert response status is correct
190
        $response->assertStatus(422);
191
192
        // assert response contain the correct message
193
        $this->assertValidationErrorContain([
194
            'email' => 'The email must be a valid email address.',
195
        ]);
196
    }
197
}
198