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
public class IntegrationWithSoundSystemTest { | |
@Test | |
public void testSoundSystem() { | |
Injector injector = Guice.createInjector(new ComputerTestModule() | |
.withInstance(SoundSystem.class, new SoundSystem())); | |
Computer computer = injector.getInstance(Computer.class); | |
// We will be satisfied with no exception being thrown |
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
public class IntegrationWithDisplaySystemTest { | |
@Test | |
public void testDisplaySystem() { | |
Injector injector = Guice.createInjector(new ComputerTestModule() | |
.withInstance(DisplaySystem.class, new DisplaySystem())); | |
Computer computer = injector.getInstance(Computer.class); | |
// We are satisfied with no exception being thrown |
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
public class ComputerTestModule extends TestModule { | |
@Override | |
protected Collection<ClassInstancePair<?>> getDefaultInstances() { | |
return Arrays.asList( | |
createClassMockPair(DisplaySystem.class), | |
createClassMockPair(SoundSystem.class)); | |
} | |
} |
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
public class ComputerTestUsingTestModule { | |
@Test | |
public void testPlayVideo() { | |
Injector injector = Guice.createInjector(new TestModule() | |
.withMockedClasses(SoundSystem.class, DisplaySystem.class)); | |
Computer computer = injector.getInstance(Computer.class); | |
SoundSystem soundSystem = injector.getInstance(SoundSystem.class); | |
DisplaySystem displaySystem = injector.getInstance(DisplaySystem.class); |
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
public class ComputerTestUsingSetter { | |
@Test | |
public void testPlayVideo() { | |
Computer computer = new Computer(); | |
MotherBoard motherBoard = new MotherBoard(); | |
SoundCard soundCard = new SoundCard(); | |
VideoCard videoCard = new VideoCard(); | |
SoundSystem soundSystem = Mockito.mock(SoundSystem.class); | |
DisplaySystem displaySystem = Mockito.mock(DisplaySystem.class); |
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
{ | |
u 'body': u 'token=SLASH_CMD_TOKEN&team_id=T1PASUPJL&team_domain=my_slack_domain&channel_id=C3GQWN08L&channel_name=integration_dev&user_id=U3GMSMREW&user_name=jdev&command=%2Fs1&text=health&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FXXXXXXXXX%2FXXXXXXXXXXXX%2FXXXXXXXXXXXXXXX', u 'resource': u '/slack/cmds/s1', u 'requestContext': { | |
u 'resourceId': u '7y5pmu', | |
u 'apiId': u 'REDACTED', | |
u 'resourcePath': u '/slack/cmds/s1', | |
u 'httpMethod': u 'POST', | |
u 'requestId': u '08b60825-d7ad-11e6-8e0c-2d47855f377e', | |
u 'accountId': u 'REDACTED', | |
u 'identity': { | |
u 'apiKey': REDACTED, |
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
#!/usr/bin/env python | |
""" Example Lambda function for Security ChatOPs""" | |
__author__ = 'Jacolon Walker' | |
__email__ = '[email protected]' | |
from urlparse import parse_qs | |
from ConfigParser import SafeConfigParser | |
import logging | |
from sentinel_core import AUTH, count_agents, fetch_agent_logs, login, threats_summary, blacklist_hash | |
import requests |
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
[creds] | |
user = consumer-account | |
passwd = auth_token_password | |
[endpoints] | |
prod_domain = https://prod.endpoint-mgmt.tld/web/api/v1.6 | |
dev_domain = https://dev.endpoint-mgmt.tld/web/api/v1.6 | |
[slack_dev] | |
webhook = https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXX/XXXXXXXXXXXXXXXX |
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
// Initialize MKLocalSearchCompleter | |
let requestCompleter = MKLocalSearchCompleter() | |
// OnDidCompleteRequestProxy | |
requestCompleter.rx_completerDidUpdateResults | |
.flatMap(filterSearchLocation) // filter search locations | |
.subscribe(onNext: { [weak self] (results) in | |
// Method to handle search completer success | |
self?.updateLocations(results) | |
}, onError: { [weak self] error in |
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
func filterSearchLocation(completer: MKLocalSearchCompleter) | |
throws -> Observable<[MKLocalSearchCompletion]> { | |
// Filter results by titles that contain "United States" keywors | |
let filteredResults = completer | |
.results | |
.filter { $0.title.contains("United States") } | |
// Throw Location not found error | |
guard filteredResults.isEmpty else { throw "Location not found"} | |
// convert an filtered results into an Observable |
NewerOlder