Issues (42)

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.

tests/MoMoTest.php (2 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
 * @link https://github.com/yiiviet/yii2-payment
4
 * @copyright Copyright (c) 2017 Yii Viet
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace yiiviet\tests\unit\payment;
9
10
/**
11
 * Lớp MoMoTest
12
 *
13
 * @author Vuong Minh <[email protected]>
14
 * @since 1.0.3
15
 */
16
class MoMoTest extends TestCase
17
{
18
19
    /**
20
     * @var \yiiviet\payment\momo\PaymentGateway
21
     */
22
    public $gateway;
23
24
    public static function gatewayId(): string
25
    {
26
        return 'MM';
27
    }
28
29
    public function testPurchase()
30
    {
31
        $orderId = microtime();
32
        $requestId = microtime();
33
        $responseData = $this->purchase([
34
            'amount' => 500000,
35
            'returnUrl' => 'http://localhost',
36
            'notifyUrl' => 'http://localhost',
37
            'orderId' => $orderId,
38
            'requestId' => $requestId
39
        ]);
40
41
        $this->assertTrue($responseData->getIsOk());
42
        $this->assertTrue($responseData->payUrl !== '');
43
44
        return [$orderId, $requestId];
45
    }
46
47
    /**
48
     * @expectedException \yii\base\InvalidConfigException
49
     * @expectedExceptionMessage cannot be blank
50
     * @depends testPurchase
51
     */
52
    public function testInvalidPurchase()
53
    {
54
        $this->purchase([]);
55
    }
56
57
    /**
58
     * @depends testPurchase
59
     */
60
    public function testQueryDR()
61
    {
62
        list($orderId, $requestId) = $this->testPurchase();
63
        $responseData = $this->queryDR([
64
            'orderId' => $orderId,
65
            'requestId' => $requestId
66
        ]);
67
68
        $this->assertTrue($responseData->getIsOk());
69
    }
70
71
    /**
72
     * @expectedException \yii\base\InvalidConfigException
73
     * @expectedExceptionMessage cannot be blank
74
     * @depends testQueryDR
75
     */
76
    public function testInvalidQueryDR()
77
    {
78
        $this->queryDR([]);
79
    }
80
81
    /**
82
     * @depends testPurchase
83
     * @depends testQueryDR
84
     */
85 View Code Duplication
    public function testRefund()
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...
86
    {
87
        list($orderId, $requestId) = $this->testPurchase();
88
        $responseData = $this->refund([
89
            'orderId' => $orderId,
90
            'transId' => $orderId,
91
            'amount' => 10000,
92
            'requestId' => $requestId
93
        ]);
94
95
        $this->assertFalse($responseData->getIsOk());
96
    }
97
98
    /**
99
     * @expectedException \yii\base\InvalidConfigException
100
     * @expectedExceptionMessage cannot be blank
101
     * @depends testRefund
102
     */
103
    public function testInvalidRefund()
104
    {
105
        $this->refund([]);
106
    }
107
108
    /**
109
     * @depends testRefund
110
     */
111 View Code Duplication
    public function testQueryRefund()
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...
112
    {
113
        list($orderId, $requestId) = $this->testPurchase();
114
        $responseData = $this->queryRefund([
115
            'orderId' => $orderId,
116
            'transId' => $orderId,
117
            'amount' => 10000,
118
            'requestId' => $requestId
119
        ]);
120
121
        $this->assertFalse($responseData->getIsOk());
122
    }
123
124
125
    /**
126
     * @expectedException \yii\base\InvalidConfigException
127
     * @expectedExceptionMessage cannot be blank
128
     * @depends testQueryRefund
129
     */
130
    public function testInvalidQueryRefund()
131
    {
132
        $this->queryRefund([]);
133
    }
134
135
    /**
136
     * @depends testPurchase
137
     * @depends testQueryDR
138
     */
139
    public function testVerifyRequestPurchaseSuccess()
140
    {
141
        $result = $this->verifyRequestPurchaseSuccess();
142
        $this->assertFalse($result);
143
    }
144
145
    /**
146
     * @depends testPurchase
147
     * @depends testQueryDR
148
     */
149
    public function testVerifyRequestIPN()
150
    {
151
        $result = $this->verifyRequestIPN();
152
153
        $this->assertFalse($result);
154
    }
155
}
156