File tree Expand file tree Collapse file tree 2 files changed +52
-2
lines changed
app/code/Magento/CustomerGraphQl/Model/Resolver
dev/tests/api-functional/testsuite/Magento/GraphQl/Customer Expand file tree Collapse file tree 2 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -44,11 +44,11 @@ public function resolve(
44
44
array $ value = null ,
45
45
array $ args = null
46
46
) {
47
- if (!isset ($ args ['email ' ])) {
47
+ if (!isset ($ args ['email ' ]) || empty ( $ args [ ' email ' ]) ) {
48
48
throw new GraphQlInputException (__ ('Specify the "email" value. ' ));
49
49
}
50
50
51
- if (!isset ($ args ['password ' ])) {
51
+ if (!isset ($ args ['password ' ]) || empty ( $ args [ ' password ' ]) ) {
52
52
throw new GraphQlInputException (__ ('Specify the "password" value. ' ));
53
53
}
54
54
Original file line number Diff line number Diff line change @@ -68,4 +68,54 @@ public function testGenerateCustomerTokenWithInvalidCredentials()
68
68
'was incorrect or your account is disabled temporarily. Please wait and try again later. ' );
69
69
$ this ->graphQlMutation ($ mutation );
70
70
}
71
+
72
+ /**
73
+ * Verify customer with empty email
74
+ */
75
+ public function testGenerateCustomerTokenWithEmptyEmail ()
76
+ {
77
+ $ email = '' ;
78
+ $ password = 'bad-password ' ;
79
+
80
+ $ mutation
81
+ = <<<MUTATION
82
+ mutation {
83
+ generateCustomerToken(
84
+ email: " {$ email }"
85
+ password: " {$ password }"
86
+ ) {
87
+ token
88
+ }
89
+ }
90
+ MUTATION ;
91
+
92
+ $ this ->expectException (\Exception::class);
93
+ $ this ->expectExceptionMessage ('GraphQL response contains errors: Specify the "email" value. ' );
94
+ $ this ->graphQlMutation ($ mutation );
95
+ }
96
+
97
+ /**
98
+ * Verify customer with empty password
99
+ */
100
+ public function testGenerateCustomerTokenWithEmptyPassword ()
101
+ {
102
+ $ email = 'customer@example.com ' ;
103
+ $ password = '' ;
104
+
105
+ $ mutation
106
+ = <<<MUTATION
107
+ mutation {
108
+ generateCustomerToken(
109
+ email: " {$ email }"
110
+ password: " {$ password }"
111
+ ) {
112
+ token
113
+ }
114
+ }
115
+ MUTATION ;
116
+
117
+ $ this ->expectException (\Exception::class);
118
+ $ this ->expectExceptionMessage ('GraphQL response contains errors: Specify the "password" value. ' );
119
+ $ this ->graphQlMutation ($ mutation );
120
+ }
71
121
}
You can’t perform that action at this time.
0 commit comments