Issues (10)

Security Analysis    no request data  

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.

tests/Submission/EntryTest.php (9 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
use Qualia\Client;
4
use Qualia\Exceptions\ConnectionErrorException;
5
use Qualia\Exceptions\EmailExistsException;
6
use Qualia\Exceptions\RequestException;
7
use Qualia\Submission\Entry;
8
9
class EntryTest extends TestCase
10
{
11
12
    public function testInvalidCredentials()
13
    {
14
        self::setExpectedException("\\Qualia\\Exceptions\\RequestException");
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
15
16
        Entry::build(new Client('597768e728d8f1508f6d9f62', 'invalid-credentials'))
17
                        ->email('q_tVabQ3cUlwZTgQ10', '[email protected]')
18
                        ->send();
19
20
    }
21
22
    public function testInvalidSurvey()
23
    {
24
        self::setExpectedException("\\Qualia\\Exceptions\\RequestException");
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
25
26
        Entry::build(new Client('aaa', 'cT6hCqyxD8MQ0k6gfYwWBt3lIMexpsLQ'))
27
                        ->email('q_tVabQ3cUlwZTgQ10', '[email protected]')
28
                        ->send();
29
30
    }
31
32
    public function testServerError()
33
    {
34
        try {
35
            Entry::build(new Client('aaa', 'cT6hCqyxD8MQ0k6gfYwWBt3lIMexpsLQ', 'api.qualiaanalytics.test'))
36
                 ->email('q_tVabQ3cUlwZTgQ10', '[email protected]')
37
                 ->send();
38
        } catch (ConnectionErrorException $e) {
39
            self::assertTrue(true);
40
        } catch (RequestException $e) {
41
            self::assertFalse(true);
42
        }
43
    }
44
45
    public function testValidationException()
46
    {
47
        try {
48
            Entry::build($this->client)
49
                 ->email('dadad', '[email protected]')
50
                 ->send();
51
        } catch (ConnectionErrorException $e) {
52
            self::assertTrue(false);
53
        } catch (EmailExistsException $e) {
54
            self::assertTrue(false);
55
        } catch (RequestException $e) {
56
            self::assertTrue(true);
57
            self::assertEquals(400, $e->getCode());
58
            self::assertEquals("Invalid Question: dadad", $e->getMessage());
59
        }
60
    }
61
62
    public function testFailsWithoutData()
63
    {
64
        self::setExpectedException("InvalidArgumentException");
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
65
66
        Entry::build($this->client)
67
                ->send();
68
    }
69
70
    public function allowsOnlyCorrectDateNotUnixTime()
71
    {
72
        self::setExpectedException("InvalidArgumentException");
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
73
74
        $id = uniqid('', true);
75
76
        Entry::build($this->client)
77
                ->uniqueId($id)
78
                ->date('q_1J75WdyBwVpwlJUM', time())
79
                ->send();
80
    }
81
82
    public function testAllowsOnlyCorrectDate()
83
    {
84
        self::setExpectedException("InvalidArgumentException");
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
85
86
        Entry::build($this->client)
87
                ->date('q_1J75WdyBwVpwlJUM', 'invalid')
88
                ->send();
89
    }
90
91
    public function testCreatesEntryWithEmail()
92
    {
93
        $id = uniqid('', true);
94
95
        $response = Entry::build($this->client)
96
                ->uniqueId($id)
97
                ->email('q_3RYJ4MpggyMFuU50', $id."[email protected]")
98
                ->send();
99
100
        self::assertEquals('success', $response['message']);
101
        self::assertArrayHasKey('id', $response);
102
    }
103
104
    public function testSingleCheckbox()
105
    {
106
        $id = uniqid('', true);
107
108
        $response = Entry::build($this->client)
109
                            ->email('q_3RYJ4MpggyMFuU50', $id."[email protected]")
110
                            ->response('q_tVabQ3cUlwZTgQ10', 'o_ACvo61cUuKXxD5C1')
111
                            ->send();
112
113
        self::assertEquals('success', $response['message']);
114
        self::assertArrayHasKey('id', $response);
115
    }
116
117
    public function testSubmitWithLanguage()
118
    {
119
        $response = Entry::build($this->client)
120
                            ->language('en')
121
                            ->date('q_1J75WdyBwVpwlJUM', date('Y-m-d'))
122
                            ->send();
123
124
        self::assertEquals('success', $response['message']);
125
        self::assertArrayHasKey('id', $response);
126
    }
127
128
    public function testSubmitWithInvalidLanguage()
129
    {
130
        $response = Entry::build($this->client)
0 ignored issues
show
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
131
                            ->language('xy')
132
                            ->date('q_1J75WdyBwVpwlJUM', date('Y-m-d'))
133
                            ->send();
134
135
        // will allow to submit and sets language as default one
136
    }
137
138
    public function testSubmitDuplicateEmail()
139
    {
140
        $id = uniqid('', true);
141
142
        $response = Entry::build($this->client)
0 ignored issues
show
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
143
                            ->email('q_3RYJ4MpggyMFuU50', $id."[email protected]")
144
                            ->send();
145
146
        // allowDuplicates will allow to submit
147
        $response = Entry::build($this->client)
0 ignored issues
show
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
148
                         ->allowDuplicates()
149
                         ->email('q_3RYJ4MpggyMFuU50', $id."[email protected]")
150
                         ->send();
151
152
        try {
153
            // will throw an exception
154
            $response = Entry::build($this->client)
0 ignored issues
show
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
155
                             ->email('q_3RYJ4MpggyMFuU50', $id."[email protected]")
156
                             ->send();
157
        } catch (EmailExistsException $e) {
158
            self::assertTrue(strlen($e->getEntryId()) > 0);
159
            return;
160
        }
161
162
        self::assertFalse(true, "Exception was not thrown");
163
    }
164
165
    public function testWithAllFields()
166
    {
167
        $id = uniqid('', true);
168
169
        $response = Entry::build($this->client)
170
                ->uniqueId($id)
171
                ->email('q_3RYJ4MpggyMFuU50', $id."[email protected]")
172
                ->name('q_KCyzOs7VqevWbEO0', "Unit", "Tester")
173
                ->date('q_1J75WdyBwVpwlJUM', date('Y-m-d'))
174
                ->response('q_KCyzOs7VqevWbEO0', ['o_wCcuY5a54YBeXLC1', 'o_ACvo61cUuKXxD5C1'])
175
                ->send();
176
177
        self::assertEquals('success', $response['message']);
178
        self::assertArrayHasKey('id', $response);
179
    }
180
181
    public function testCreatesEntryWithEmailAndMarksCompleted()
182
    {
183
        $id = uniqid('', true);
184
185
        $response = Entry::build($this->client)
186
                ->uniqueId($id)
187
                ->email('q_3RYJ4MpggyMFuU50', $id."[email protected]")
188
                ->send(true);
189
190
        self::assertEquals('success', $response['message']);
191
        self::assertArrayHasKey('id', $response);
192
    }
193
}