Changeset 59084
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-application-passwords.php
r59009 r59084 93 93 if ( empty( $args['name'] ) ) { 94 94 return new WP_Error( 'application_password_empty_name', __( 'An application name is required to create an application password.' ), array( 'status' => 400 ) ); 95 }96 97 if ( self::application_name_exists_for_user( $user_id, $args['name'] ) ) {98 return new WP_Error( 'application_password_duplicate_name', __( 'Each application name should be unique.' ), array( 'status' => 409 ) );99 95 } 100 96 -
trunk/tests/e2e/specs/profile/applications-passwords.test.js
r59046 r59084 40 40 ); 41 41 } ); 42 43 test('should not allow to create two applications passwords with the same name', async ( {44 page,45 applicationPasswords46 } ) => {47 await applicationPasswords.create();48 await applicationPasswords.create();49 50 const errorMessage = page.getByRole( 'alert' );51 52 await expect( errorMessage ).toHaveClass( /notice-error/ );53 await expect(54 errorMessage55 ).toContainText(56 'Each application name should be unique.'57 );58 });59 42 60 43 test( 'should correctly revoke a single application password', async ( { -
trunk/tests/phpunit/tests/rest-api/application-passwords.php
r55457 r59084 78 78 'args' => array( 'name' => '<script>console.log("Hello")</script>' ), 79 79 ), 80 'application_password_duplicate_name when name exists' => array(81 'expected' => array(82 'error_code' => 'application_password_duplicate_name',83 'error_message' => 'Each application name should be unique.',84 ),85 'args' => array( 'name' => 'test2' ),86 'names' => array( 'test1', 'test2' ),87 ),88 80 ); 89 81 } … … 197 189 ); 198 190 } 191 192 /** 193 * @ticket 51941 194 */ 195 public function test_can_create_duplicate_app_password_names() { 196 $created = WP_Application_Passwords::create_new_application_password( self::$user_id, array( 'name' => 'My App' ) ); 197 $this->assertNotWPError( $created, 'First attempt to create an application password should not return an error' ); 198 $created = WP_Application_Passwords::create_new_application_password( self::$user_id, array( 'name' => 'My App' ) ); 199 $this->assertNotWPError( $created, 'Second attempt to create an application password should not return an error' ); 200 } 199 201 }
Note: See TracChangeset
for help on using the changeset viewer.