-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix]icl-1495 imanager节点管理例子无法访问 review by qiw
- Loading branch information
1 parent
ca75373
commit 81c9b3a
Showing
7 changed files
with
112 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { IManager } from '../../../src/common/IManager/IManager'; | ||
import { FetchRequest } from '../../../src/common/util/FetchRequest'; | ||
import { SecurityManager } from '../../../src/common/security/SecurityManager'; | ||
|
||
SecurityManager.imanagerToken = 'test'; | ||
describe('IManager', () => { | ||
it('iServerList', (done) => { | ||
var imanager = new IManager('https://fake/imanager'); | ||
expect(imanager).not.toBeNull(); | ||
spyOn(FetchRequest, 'get').and.callFake((testUrl, params, options) => { | ||
expect(options.headers['X-Auth-Token']).toBe('test'); | ||
expect(testUrl).toBe('https://fake/imanager/cloud/web/nodes/server.json'); | ||
return Promise.resolve(new Response(`{"list":[],"total":0}`)); | ||
}); | ||
imanager.iServerList().then(function (response) { | ||
const res = JSON.stringify(response); | ||
expect(res).toBe('{"list":[],"total":0}'); | ||
done(); | ||
}); | ||
}); | ||
it('createIServer', (done) => { | ||
var imanager = new IManager('https://fake/imanager'); | ||
expect(imanager).not.toBeNull(); | ||
spyOn(FetchRequest, 'post').and.callFake((testUrl, params, options) => { | ||
expect(options.headers['X-Auth-Token']).toBe('test'); | ||
expect(testUrl).toBe('https://fake/imanager/cloud/web/nodes/server.json'); | ||
return Promise.resolve(new Response(`{"isSucceed":true}`)); | ||
}); | ||
imanager.createIServer({}).then(function (response) { | ||
const res = JSON.stringify(response); | ||
expect(res).toBe('{"isSucceed":true}'); | ||
done(); | ||
}); | ||
}); | ||
it('startNodes', (done) => { | ||
var imanager = new IManager('https://fake/imanager'); | ||
expect(imanager).not.toBeNull(); | ||
spyOn(FetchRequest, 'post').and.callFake((testUrl, params, options) => { | ||
expect(options.headers['X-Auth-Token']).toBe('test'); | ||
expect(testUrl).toBe('https://fake/imanager/cloud/web/nodes/started.json'); | ||
return Promise.resolve(new Response(`{"isSucceed":true}`)); | ||
}); | ||
imanager.startNodes([1]).then(function (response) { | ||
const res = JSON.stringify(response); | ||
expect(res).toBe('{"isSucceed":true}'); | ||
done(); | ||
}); | ||
}); | ||
it('stopNodes', (done) => { | ||
SecurityManager.imanagerToken = 'test'; | ||
var imanager = new IManager('https://fake/imanager'); | ||
expect(imanager).not.toBeNull(); | ||
spyOn(FetchRequest, 'post').and.callFake((testUrl, params, options) => { | ||
expect(options.headers['X-Auth-Token']).toBe('test'); | ||
expect(testUrl).toBe('https://fake/imanager/cloud/web/nodes/stopped.json'); | ||
return Promise.resolve(new Response(`{"isSucceed":true}`)); | ||
}); | ||
imanager.stopNodes([1]).then(function (response) { | ||
const res = JSON.stringify(response); | ||
expect(res).toBe('{"isSucceed":true}'); | ||
done(); | ||
}); | ||
}); | ||
}); |
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