Determining auth type in a pre-request script

Iโ€™m writing tests for a service that uses either Bearer or Basic authorization but requires slightly different request URLs for the two authorization types. I want to be able to specify authorization at the collection level (except as noted in the next paragraph) and have the requests adjust themselves to match the requirements of the selected authorization type.

The collection includes a folder of requests that override the collection-level authorization in order to make sure both types of authorization are working, regardless of which type is selected for the other tests in the collection.

Iโ€™ve attempted to write a collection-level pre-request script that checks the requestโ€™s authorization type in order to adjust the URL as necessary, but the Authorization header is not set when the script runs, and I havenโ€™t been able to find any other way to check the requestโ€™s authorization type.

For example, the following pre-request script always sets an auth-header variable to โ€˜(none)โ€™ if no Authorization header is manually defined, even if authorization is configured. The auth-type value is set to โ€˜(no auth)โ€™.

pm.environment.set('auth-header', pm.request.getHeaders()['Authorization'] || '(none)');
if (pm.request.auth) {
  pm.environment.set('auth-type', pm.request.auth.type || '(auth, no type)');
}
else {
  pm.environment.set('auth-type', '(no auth)');
}

Am I missing something, or is this just not possible? I suppose I could set the authorization in pre-request scripts based on the value of an environment variable, but I think that would be harder to understand and maintain.

@JessePelton This is because the auth property on the request is meant to represent the authentication helper associated with that request itself. Hence, details on the actual auth helper being used (inherited) from one of the parents would not be present here. This would be a useful addition to the contextual information provided within the sandboxed testing environment, thanks for pointing it out.

@kunagpal, should I file an enhancement request?

Yes, could you create one here: https://github.com/postmanlabs/postman-app-support/issues/new?

What is the latest status of this matter / enhancement?
Iโ€™m also faced with this matter, and trying to do what the user who posted this, tried.