mirror of
https://github.com/actions/setup-java.git
synced 2026-07-20 14:32:57 +00:00
Clarify credential environment variable inputs (#1134)
* Clarify credential environment variable inputs Rename credential-related inputs to make their environment-variable semantics explicit while preserving deprecated aliases with migration warnings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 70a3daa8-dbc9-4eb0-a57b-df198a459315 * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -270,4 +270,55 @@ describe('auth tests', () => {
|
||||
expectedSettings
|
||||
);
|
||||
});
|
||||
|
||||
it('uses deprecated input aliases and warns', () => {
|
||||
const mockGetInput = core.getInput as jest.MockedFunction<
|
||||
typeof core.getInput
|
||||
>;
|
||||
const mockWarning = core.warning as jest.MockedFunction<
|
||||
typeof core.warning
|
||||
>;
|
||||
mockGetInput.mockImplementation(name =>
|
||||
name === 'server-username' ? 'LEGACY_USERNAME' : ''
|
||||
);
|
||||
|
||||
expect(
|
||||
auth.getInputWithDeprecatedAlias(
|
||||
'server-username-env-var',
|
||||
'server-username',
|
||||
'GITHUB_ACTOR'
|
||||
)
|
||||
).toBe('LEGACY_USERNAME');
|
||||
expect(mockWarning).toHaveBeenCalledWith(
|
||||
"The 'server-username' input is deprecated and may be removed in a future release. Please use 'server-username-env-var' instead."
|
||||
);
|
||||
|
||||
mockGetInput.mockReset();
|
||||
mockWarning.mockReset();
|
||||
});
|
||||
|
||||
it('prefers the replacement input over its deprecated alias', () => {
|
||||
const mockGetInput = core.getInput as jest.MockedFunction<
|
||||
typeof core.getInput
|
||||
>;
|
||||
mockGetInput.mockImplementation(name => {
|
||||
const inputs: Record<string, string> = {
|
||||
'server-password-env-var': 'NEW_PASSWORD',
|
||||
'server-password': 'LEGACY_PASSWORD'
|
||||
};
|
||||
return inputs[name] || '';
|
||||
});
|
||||
|
||||
expect(
|
||||
auth.getInputWithDeprecatedAlias(
|
||||
'server-password-env-var',
|
||||
'server-password',
|
||||
'GITHUB_TOKEN'
|
||||
)
|
||||
).toBe('NEW_PASSWORD');
|
||||
expect(core.warning).toHaveBeenCalled();
|
||||
|
||||
mockGetInput.mockReset();
|
||||
(core.warning as jest.Mock).mockReset();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user