-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
442 additions
and
28 deletions.
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
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
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
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
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
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,41 @@ | ||
import { eventLog } from './eventLog' | ||
import { createSpyObj } from '../../test/helper/jest' | ||
import { devices } from '../../server/mpsserver' | ||
import { ConnectedDevice } from '../../amt/ConnectedDevice' | ||
import { amtMessageLog } from '../../test/helper/wsmanResponses' | ||
|
||
describe('event log', () => { | ||
let resSpy | ||
let req | ||
let eventLogSpy | ||
beforeEach(() => { | ||
resSpy = createSpyObj('Response', ['status', 'json', 'end', 'send']) | ||
req = { params: { guid: '4c4c4544-004b-4210-8033-b6c04f504633' } } | ||
resSpy.status.mockReturnThis() | ||
resSpy.json.mockReturnThis() | ||
resSpy.send.mockReturnThis() | ||
|
||
devices['4c4c4544-004b-4210-8033-b6c04f504633'] = new ConnectedDevice(null, 'admin', 'P@ssw0rd') | ||
eventLogSpy = jest.spyOn(devices['4c4c4544-004b-4210-8033-b6c04f504633'], 'getEventLog') | ||
}) | ||
|
||
it('should get version', async () => { | ||
eventLogSpy.mockResolvedValueOnce(amtMessageLog) | ||
await eventLog(req, resSpy) | ||
expect(resSpy.status).toHaveBeenCalledWith(200) | ||
}) | ||
it('should get an error with status code 400, when get version is null', async () => { | ||
eventLogSpy.mockResolvedValueOnce(null) | ||
await eventLog(req, resSpy) | ||
expect(resSpy.status).toHaveBeenCalledWith(400) | ||
expect(resSpy.json).toHaveBeenCalledWith({ error: 'Incorrect URI or Bad Request', errorDescription: 'Failed during GET MessageLog guid : 4c4c4544-004b-4210-8033-b6c04f504633.' }) | ||
}) | ||
it('should get an error with status code 500 for an unexpected exception', async () => { | ||
eventLogSpy.mockImplementation(() => { | ||
throw new Error() | ||
}) | ||
await eventLog(req, resSpy) | ||
expect(resSpy.status).toHaveBeenCalledWith(500) | ||
expect(resSpy.json).toHaveBeenCalledWith({ error: 'Internal Server Error', errorDescription: 'Request failed during AMT EventLog.' }) | ||
}) | ||
}) |
Oops, something went wrong.