-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"env": { | ||
"test": { | ||
"presets": [["@babel/preset-env"]] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import AuthType from "../lib/auth/types/AuthType"; | ||
|
||
const mockServer = { | ||
config: () => { | ||
return { | ||
get: () => { | ||
return null; | ||
} | ||
} | ||
} | ||
} | ||
|
||
describe('AuthType tests', () => { | ||
it('should contain only security_impersonate_as when no additional headers are passed', () => { | ||
// act | ||
var authType = new AuthType(null, mockServer, null, null, null, {}); | ||
// assert | ||
expect(authType.allowedAdditionalAuthHeaders).toHaveLength(1); | ||
expect(authType.allowedAdditionalAuthHeaders).toContain("security_impersonate_as"); | ||
}); | ||
|
||
it('should add whitelisted headers when present', () => { | ||
// arrange | ||
const mockEsConfig = { | ||
requestHeadersWhitelist: ["test-header-1", "test-header-2"] | ||
} | ||
// act | ||
var authType = new AuthType(null, mockServer, null, null, null, mockEsConfig); | ||
// assert | ||
expect(authType.allowedAdditionalAuthHeaders).toHaveLength(3); | ||
expect(authType.allowedAdditionalAuthHeaders).toContain("security_impersonate_as"); | ||
expect(authType.allowedAdditionalAuthHeaders).toContain("test-header-1"); | ||
expect(authType.allowedAdditionalAuthHeaders).toContain("test-header-2") | ||
}); | ||
}); |