fix: sas9 public access denied handling - #755
Conversation
Coverage reportTotal coverage
Show files with reduced coverage 🔻Reduced coverage
Report generated by 🧪jest coverage report action from 3556eb3 |
|
@medjedovicm please a test cases for both scenarios |
| new ErrorResponse('Public access has been denied', responseObject) | ||
| ) | ||
|
|
||
| resolve(responseObject) |
There was a problem hiding this comment.
Bug: resolve(responseObject) on the next line will still execute after reject() is called. While the Promise is already settled (so resolve is a no-op), this is fragile and misleading. Add a return before reject:
if (this.isPublicAccessDenied(jsonResponse))
return reject(
new ErrorResponse('Public access has been denied', responseObject)
)| } | ||
|
|
||
| private isPublicAccessDenied = (response: string): boolean => { | ||
| return /Public access has been denied/gm.test(response) |
There was a problem hiding this comment.
The isPublicAccessDenied function is duplicated — the same regex check exists as a module-level function in AuthManager.ts (line 414). Consider extracting it to a shared utility (e.g. utils/isPublicAccessDenied.ts) and importing in both places, to avoid drift if the error message pattern changes.
| if (!(err instanceof NotFoundError)) throw err | ||
|
|
||
| return { | ||
| result: '' |
There was a problem hiding this comment.
The .catch() returns { result: '' } but the success path returns the full RequestClient.get response (which has .result plus other fields like .log). The caller does casSecurityCheckResponse.result so this works, but the return types are inconsistent — the catch path produces a partial object. Consider typing the return explicitly or using { result: '', log: '' } for consistency.
There was a problem hiding this comment.
Hermes Agent Code Review
Verdict: Request Changes — 1 bug, 2 warnings, merge conflict
Blocking Issues
-
Merge conflict — this PR is currently not mergeable (
mergeable_state: dirty). Please rebase againstmainand resolve conflicts before this review can be considered for merge. -
Bug:
WebJobExecutor.ts:196—resolve(responseObject)executes afterreject()on the public-access-denied path. While the Promise is already settled (soresolveis a no-op), this is fragile and could break if the code is refactored. Addreturnbeforereject:
if (this.isPublicAccessDenied(jsonResponse))
return reject(
new ErrorResponse('Public access has been denied', responseObject)
)Warnings
-
Duplicated
isPublicAccessDenied— The same regex check exists in bothAuthManager.ts(module-level) andWebJobExecutor.ts(private method). Extract to a shared utility to avoid drift. -
Inconsistent return type in
performCASSecurityCheckcatch — The.catch()returns{ result: '' }(partial object) while the success path returns the full response with.result,.log, etc. Type the return explicitly for safety.
Looks Good
- Good test coverage: two new spec tests covering both
logInandredirectedLogInpaths for the public-access-denied scenario - The
errorMessagefield addition toLoginResultis clean and backward-compatible (optional field) - The regex pattern
/Public access has been denied/gmis consistent across both implementations - Mock response added to
mockResponses.tsfor test reuse
Reviewed by Hermes Agent (GitHub App)
Issue
Fixes #150
Intent
Covers the SAS9
Public Access Deniedscenario. 2 places touched:login()- User is not logged in. The login function is called withPublic Accountcredentials. The adapter will return an object that contains an error message with error details andloggedInis false. (image 1.)request()- User withPublic Accountis already logged in within current browser. App loads,requestfunction is called. The adapter will throw an error with details inside. (image 2.)image 1.

image 2.

Checks
No PR (that involves a non-trivial code change) should be merged, unless all items below are confirmed! If an urgent fix is needed - use a tar file.
sasjs-cliunit tests are passing (npm test).sasjs-testsare passing. If you want to run it manually (instructions available here).