jstests/auth/change_stream_pre_image_coll_role_auth.js
// The parameter 'isAuthorized' determines if the authorization should pass or fail.
The parameter 'isAuthorized' determines if the authorization should pass or fail.
The parameter ' isAuthorized ' determines if the authorization should pass or fail .
function assertActionAuthorized(actionFunc, isAuthorized) {
    try {
        actionFunc();
        assert.eq(isAuthorized, true, "authorization passed unexpectedly");
    } catch (ex) {
        assert.eq(isAuthorized, false, "authorization failed unexpectedly, details: " + ex);
        const unauthorized = 13;
        assert.eq(ex.code,
                  unauthorized,
                  "expected operation should fail with code: " + unauthorized +
                      ", found: " + ex.code + ", details: " + ex);
    }
}
function assertActionAuthorized ( actionFunc , isAuthorized ) { try { actionFunc ( ) ; assert . eq ( isAuthorized , true , "authorization passed unexpectedly" ) ; } catch ( ex ) { assert . eq ( isAuthorized , false , "authorization failed unexpectedly, details: " + ex ) ; const unauthorized = 13 ; assert . eq ( ex . code , unauthorized , "expected operation should fail with code: " + unauthorized + ", found: " + ex . code + ", details: " + ex ) ; } }
The parameter 'isAuthorized' determines if the authorization should pass or fail.
The parameter ' isAuthorized ' determines if the authorization should pass or fail .
// Verify if the authorization is expected to pass. // Verify if the authorization is expected to fail. // Verify that the authorization failed with the expected error code.