Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/analyze-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/init-action-post.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/setup-codeql-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/upload-lib.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/upload-sarif-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 23 additions & 30 deletions src/api-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,37 +171,30 @@ test("wrapApiConfigurationError correctly wraps specific configuration errors",
);

// Enablement errors.
const codeSecurityNotEnabledError = new util.HTTPError(
const enablementErrorMessages = [
"Code Security must be enabled for this repository to use code scanning",
403,
);
res = api.wrapApiConfigurationError(codeSecurityNotEnabledError);
t.deepEqual(
res,
new util.ConfigurationError(
api.getFeatureEnablementError(codeSecurityNotEnabledError.message),
),
);
const advancedSecurityNotEnabledError = new util.HTTPError(
"Advanced Security must be enabled for this repository to use code scanning",
403,
);
res = api.wrapApiConfigurationError(advancedSecurityNotEnabledError);
t.deepEqual(
res,
new util.ConfigurationError(
api.getFeatureEnablementError(advancedSecurityNotEnabledError.message),
),
);
const codeScanningNotEnabledError = new util.HTTPError(
"Code Scanning is not enabled for this repository. Please enable code scanning in the repository settings.",
403,
);
res = api.wrapApiConfigurationError(codeScanningNotEnabledError);
t.deepEqual(
res,
new util.ConfigurationError(
api.getFeatureEnablementError(codeScanningNotEnabledError.message),
),
);
];
const transforms = [
(msg: string) => msg,
(msg: string) => msg.toLowerCase(),
(msg: string) => msg.toLocaleUpperCase(),
];

for (const enablementErrorMessage of enablementErrorMessages) {
for (const transform of transforms) {
const enablementError = new util.HTTPError(
transform(enablementErrorMessage),
403,
);
res = api.wrapApiConfigurationError(enablementError);
t.deepEqual(
res,
new util.ConfigurationError(
api.getFeatureEnablementError(enablementError.message),
),
);
}
}
});
6 changes: 3 additions & 3 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ export async function getRepositoryProperties(repositoryNwo: RepositoryNwo) {

function isEnablementError(msg: string) {
return [
/Code Security must be enabled/,
/Advanced Security must be enabled/,
/Code Scanning is not enabled/,
/Code Security must be enabled/i,
/Advanced Security must be enabled/i,
/Code Scanning is not enabled/i,
].some((pattern) => pattern.test(msg));
}

Expand Down
Loading