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/unit/MembershipApplicationTest.php (1 issue)

Labels
Severity

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
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Store\Tests;
6
7
use PHPUnit\Framework\TestCase;
8
use WMDE\Fundraising\Entities\MembershipApplication;
9
use WMDE\Fundraising\Store\MembershipApplicationData;
10
11
/**
12
 * @covers \WMDE\Fundraising\Entities\MembershipApplication
13
 * @covers \WMDE\Fundraising\Store\MembershipApplicationData
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class MembershipApplicationTest extends TestCase {
19
20
	public function testWhenSettingIdToAnInteger_getIdReturnsIt() {
21
		$application = new MembershipApplication();
22
		$application->setId( 1337 );
23
24
		$this->assertSame( 1337, $application->getId() );
25
	}
26
27
	public function testWhenSettingIdToNull_getIdReturnsNull() {
28
		$application = new MembershipApplication();
29
		$application->setId( 1337 );
30
		$application->setId( null );
31
32
		$this->assertNull( $application->getId() );
33
	}
34
35
	public function testWhenIdIsNotSet_getIdReturnsNull() {
36
		$application = new MembershipApplication();
37
38
		$this->assertNull( $application->getId() );
39
	}
40
41
	public function testGivenNoData_getDataObjectReturnsObjectWithNullValues() {
42
		$application = new MembershipApplication();
43
44
		$this->assertNull( $application->getDataObject()->getAccessToken() );
45
		$this->assertNull( $application->getDataObject()->getUpdateToken() );
46
		$this->assertNull( $application->getDataObject()->getPreservedStatus() );
47
	}
48
49
	public function testWhenProvidingData_setDataObjectSetsData() {
50
		$data = new MembershipApplicationData();
51
		$data->setAccessToken( 'foo' );
52
		$data->setUpdateToken( 'bar' );
53
		$data->setPreservedStatus( 1337 );
54
55
		$application = new MembershipApplication();
56
		$application->setDataObject( $data );
57
58
		$this->assertSame(
59
			[
60
				'token' => 'foo',
61
				'utoken' => 'bar',
62
				'old_status' => 1337,
63
			],
64
			$application->getDecodedData()
65
		);
66
	}
67
68
	public function testWhenProvidingNullData_setObjectDoesNotSetFields() {
69
		$application = new MembershipApplication();
70
		$application->setDataObject( new MembershipApplicationData() );
71
72
		$this->assertSame(
73
			[],
74
			$application->getDecodedData()
75
		);
76
	}
77
78
	public function testWhenDataAlreadyExists_setDataObjectRetainsAndUpdatesData() {
79
		$application = new MembershipApplication();
80
		$application->encodeAndSetData( [
81
			'nyan' => 'cat',
82
			'token' => 'wee',
83
			'pink' => 'fluffy',
84
		] );
85
86
		$data = new MembershipApplicationData();
87
		$data->setAccessToken( 'foo' );
88
		$data->setUpdateToken( 'bar' );
89
90
		$application->setDataObject( $data );
91
92
		$this->assertSame(
93
			[
94
				'nyan' => 'cat',
95
				'token' => 'foo',
96
				'pink' => 'fluffy',
97
				'utoken' => 'bar',
98
			],
99
			$application->getDecodedData()
100
		);
101
	}
102
103
	public function testWhenModifyingTheDataObject_modificationsAreReflected() {
104
		$application = new MembershipApplication();
105
		$application->encodeAndSetData( [
106
			'nyan' => 'cat',
107
			'token' => 'wee',
108
			'pink' => 'fluffy',
109
		] );
110
111
		$application->modifyDataObject( function( MembershipApplicationData $data ) {
112
			$data->setAccessToken( 'foo' );
113
			$data->setUpdateToken( 'bar' );
114
		} );
115
116
		$this->assertSame(
117
			[
118
				'nyan' => 'cat',
119
				'token' => 'foo',
120
				'pink' => 'fluffy',
121
				'utoken' => 'bar',
122
			],
123
			$application->getDecodedData()
124
		);
125
	}
126
127
	public function testStatusConstantsExist() {
128
		$this->assertNotNull( MembershipApplication::STATUS_MODERATION );
129
		$this->assertNotNull( MembershipApplication::STATUS_ABORTED );
130
		$this->assertNotNull( MembershipApplication::STATUS_CANCELED );
131
		$this->assertNotNull( MembershipApplication::STATUS_CONFIRMED );
132
		$this->assertNotNull( MembershipApplication::STATUS_DELETED );
133
		$this->assertNotNull( MembershipApplication::STATUS_NEUTRAL );
134
	}
135
136
	public function testGivenModerationStatus_needsModerationReturnsTrue() {
137
		$application = new MembershipApplication();
138
		$application->setStatus( MembershipApplication::STATUS_MODERATION );
139
140
		$this->assertTrue( $application->needsModeration() );
141
	}
142
143
	public function testGivenDefaultStatus_needsModerationReturnsFalse() {
144
		$application = new MembershipApplication();
145
146
		$this->assertFalse( $application->needsModeration() );
147
	}
148
149
	public function testGivenModerationAndCancelledStatus_needsModerationReturnsTrue() {
150
		$application = new MembershipApplication();
151
		$application->setStatus(
152
			MembershipApplication::STATUS_MODERATION + MembershipApplication::STATUS_CANCELED
153
		);
154
155
		$this->assertTrue( $application->needsModeration() );
156
	}
157
158
	public function testGivenCancelledStatus_isCancelledReturnsTrue() {
159
		$application = new MembershipApplication();
160
		$application->setStatus( MembershipApplication::STATUS_CANCELED );
161
162
		$this->assertTrue( $application->isCancelled() );
163
	}
164
165
	public function testGivenDefaultStatus_isCancelledReturnsFalse() {
166
		$application = new MembershipApplication();
167
168
		$this->assertFalse( $application->isCancelled() );
169
	}
170
171
	public function testGivenModerationAndCancelledStatus_isCancelledReturnsTrue() {
172
		$application = new MembershipApplication();
173
		$application->setStatus(
174
			MembershipApplication::STATUS_MODERATION + MembershipApplication::STATUS_CANCELED
175
		);
176
177
		$this->assertTrue( $application->isCancelled() );
178
	}
179
180
	public function testGivenDeletedStatus_isDeletedReturnsTrue() {
181
		$application = new MembershipApplication();
182
		$application->setStatus( MembershipApplication::STATUS_DELETED );
183
184
		$this->assertTrue( $application->isDeleted() );
185
	}
186
187
	public function testGivenDefaultStatus_isDeletedReturnsFalse() {
188
		$application = new MembershipApplication();
189
190
		$this->assertFalse( $application->isCancelled() );
191
	}
192
193
	public function testGivenModerationAndDeletedStatus_isDeletedReturnsTrue() {
194
		$application = new MembershipApplication();
195
		$application->setStatus(
196
			MembershipApplication::STATUS_MODERATION + MembershipApplication::STATUS_DELETED
197
		);
198
199
		$this->assertTrue( $application->isDeleted() );
200
	}
201
202
	public function testDefaultDonationReceiptValue_isNull(): void {
203
		$application = new MembershipApplication();
204
205
		$this->assertNull( $application->getDonationReceipt() );
206
	}
207
208
	public function testSetDonationReceiptValue_canBeRetrieved(): void {
209
		$application = new MembershipApplication();
210
		$application->setDonationReceipt( false );
211
212
		$this->assertFalse( $application->getDonationReceipt() );
0 ignored issues
show
It seems like $application->getDonationReceipt() targeting WMDE\Fundraising\Entitie...n::getDonationReceipt() can also be of type null; however, PHPUnit\Framework\Assert::assertFalse() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
213
	}
214
215
}
216