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(
4444 array $ value = null ,
4545 array $ args = null
4646 ) {
47- if (!isset ($ args ['email ' ])) {
47+ if (!isset ($ args ['email ' ]) || empty ( $ args [ ' email ' ]) ) {
4848 throw new GraphQlInputException (__ ('Specify the "email" value. ' ));
4949 }
5050
51- if (!isset ($ args ['password ' ])) {
51+ if (!isset ($ args ['password ' ]) || empty ( $ args [ ' password ' ]) ) {
5252 throw new GraphQlInputException (__ ('Specify the "password" value. ' ));
5353 }
5454
Original file line number Diff line number Diff line change @@ -68,4 +68,54 @@ public function testGenerateCustomerTokenWithInvalidCredentials()
6868 'was incorrect or your account is disabled temporarily. Please wait and try again later. ' );
6969 $ this ->graphQlMutation ($ mutation );
7070 }
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+ 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+ }
71121}
You can’t perform that action at this time.
0 commit comments