Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure authentication is randomized as expected (#86188)
In #85255, some mocking of Authentication class got replaced by randomly creating actual Authentication objects. This is a general direction we want to head towards because Authentication object has plenty internal logics which makes it hard to mock correctly (and also undesirable). The recent change in #85590 adds a test helper which makes randomising Authentication object easier for tests. For ApiKeyServiceTests.testGetApiKeyMetadata, the randomisation is however too broad (broader then what the mocking provided) and can sometimes creates authentication object that does not pass the assertion. The assertion expects no API key authentication. But the randomisation can generate such one because it randomises whether the authentication has run-as even when the effective user is from a realm. Since API keys can run-as, the resulted Authentication object can be an overall API key authentication object. This PR reduces the randomness by not allow run-as so that the resulted Authentication cannot be API keys. Relates: #85255 Resolves: #86179
- Loading branch information