-
Notifications
You must be signed in to change notification settings - Fork 768
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bundled fleetspeak: make fleetspeak the default. * Sandboxing: move sandboxing options from `Platform:` context to `Target:` context. * Implement UI for recollecting VFS files. * Implement Store layer for recollecting VFS files.
- Loading branch information
Showing
10 changed files
with
343 additions
and
19 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
61 changes: 61 additions & 0 deletions
61
grr/server/grr_response_server/gui/ui/lib/api/http_api_service_test_util.ts
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,61 @@ | ||
/** Test helpers. */ | ||
// tslint:disable:no-any | ||
|
||
import {TestBed} from '@angular/core/testing'; | ||
import {Observable, Subject} from 'rxjs'; | ||
|
||
import {HttpApiService} from './http_api_service'; | ||
|
||
type Func = (...args: any[]) => any; | ||
|
||
type MockService<T> = { | ||
[K in keyof T]: T[K] extends Function ? jasmine.Spy&T[K] : T[K]; | ||
}&{ | ||
readonly mockedObservables: { | ||
[K in keyof T]: T[K] extends Func ? | ||
ReturnType<T[K]> extends Observable<infer V>? Subject<V>: never : | ||
never; | ||
} | ||
}; | ||
|
||
/** HttpApiService with Spy properties and mocked Observable return values. */ | ||
export declare interface HttpApiServiceMock extends | ||
MockService<HttpApiService> {} | ||
|
||
/** | ||
* Mocks a HttpApiService, replacing methods with jasmine spies that return | ||
* Observables from `httpApiServiceMock.mockedObservables`. | ||
*/ | ||
export function mockHttpApiService(): HttpApiServiceMock { | ||
const mockHttpClient = { | ||
get: jasmine.createSpy('get').and.callFake(() => new Subject()), | ||
post: jasmine.createSpy('post').and.callFake(() => new Subject()), | ||
}; | ||
const service: any = new HttpApiService(mockHttpClient as any); | ||
const mockedObservables: any = {}; | ||
|
||
const properties = Object.getOwnPropertyNames(HttpApiService.prototype) | ||
.filter(key => service[key] instanceof Function); | ||
|
||
for (const property of properties) { | ||
mockedObservables[property] = new Subject(); | ||
service[property] = jasmine.createSpy(property).and.callFake( | ||
() => mockedObservables[property].asObservable()); | ||
} | ||
|
||
service.mockedObservables = mockedObservables; | ||
return service; | ||
} | ||
|
||
/** Injects the MockStore for the given Store class. */ | ||
export function injectHttpApiServiceMock(): HttpApiServiceMock { | ||
const mock = TestBed.inject(HttpApiService) as unknown as HttpApiServiceMock; | ||
|
||
if (!mock.mockedObservables) { | ||
const val = JSON.stringify(mock).slice(0, 100); | ||
throw new Error(`TestBed.inject(HttpApiService) returned ${ | ||
val}, which does not look like HttpApiServiceMock. Did you register the HttpApiService providers?`); | ||
} | ||
|
||
return mock; | ||
} |
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
Oops, something went wrong.