Skip to content

Commit

Permalink
REST: Don't call login() on the root user
Browse files Browse the repository at this point in the history
We've encountered a scenario in which creating edit tags via
action.makeTag() failed after creating a bot user. The error message
indicated that the tag was attempted to be created by the bot user, even
though action.makeTag() is supposed to always create them using the root
user, see: https://github.com/wikimedia/mediawiki-tools-api-testing/blob/f19ecd38750739907d14bf4a07bb20249a27407b/lib/action_clients.js#L26

It turns out that the issue was calling root.login(), which confusingly
leads to the reference to the global root user singleton to be
overridden with whatever account is logging in. This is solved here by
simply logging in from a new anonymous user object instead of using the
root user object.

Change-Id: Ida293e426868b20afa57553bd39fa2eaa3c4e040
  • Loading branch information
jakobw committed Jan 27, 2025
1 parent eb5d3a8 commit 1ac973e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions repo/rest-api/tests/mocha/helpers/testUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ async function createUser( purpose, groups ) {
} )
);

await root.login( name, password ); // root is now the new user
const user = action.getAnon();
await user.login( name, password );

return root;
return user;
}

async function getOrCreateBotUser() {
Expand Down

0 comments on commit 1ac973e

Please sign in to comment.