I have many functions in my canister operate on the logged-in user by way of the msg.caller property, for example a function like this:
public shared(msg) func getUserName() : Text {
return getProfile(msg.caller).name;
}
But when I try to test this function in the auto-generated candid interface, it always uses the anonymous user so I can never test that it’s actually able to find and operate on specific users.
Is it possible to spoof a user in the candid UI so I can test these functions?
Not out of the box, but maybe that’s something @chenyan wants to add? Could be a cool feature and I think @PaulLiu even implemented “login” via pem file for tipjar
The latest on this is that there’s a library, @dfinity/candid-ui, which provides a web component you can accept an identity while providing the base candid UI experience. Check out the docs at
You can use it locally for testing, or you can embed it inside your dapp to give your users easy ability to interact with arbitrary canisters using their already authenticated identity in your site