public async Task ShouldOAuthRequest() { await FHClient.Init(); //given ServiceFinder.RegisterType <IOAuthClientHandlerService, MockOAuthClient>(); var json = JObject.Parse(@"{ ""hosts"": {""host"": ""HOST""} }"); var config = new FHConfig(new MockDeviceService()); var props = new CloudProps(json, config); var authRequest = new FHAuthRequest(props); authRequest.SetAuthUser("gmail", "user", "password"); var mockHttpCLient = new MockHttpClient { Content = "{\"status\": \"ok\", \"url\": \"http://oauthurl.url\"}" }; FHHttpClientFactory.Get = () => mockHttpCLient; //when var response = await authRequest.ExecAsync(); //then Assert.IsNotNull(response); var responseParams = response.GetResponseAsDictionary(); Assert.IsNotNull(responseParams); Assert.AreEqual("token", responseParams["sessionToken"]); }
public void TestURLFormatting() { // given var json = JObject.Parse(@"{ 'url': 'http://someserver.com/', 'hosts': {'host': 'HOST', 'environment': 'ENV'} }"); var config = new FHConfig(new MockDeviceService()); var props = new CloudProps(json, config); // when var host = props.GetCloudHost(); // then Assert.AreEqual("http://someserver.com", host); }
public void TestReadCloudPropsWithJsonEmptyValuesForUrlAndHostWithoutUrl() { // given var json = JObject.Parse(@"{ 'hosts': {'host': 'HOST', 'environment': 'ENV', 'releaseCloudUrl': 'RELEASE_CLOUD_URL'} }"); var config = new FHConfig(new MockDeviceService()); var props = new CloudProps(json, config); // when var host = props.GetCloudHost(); var env = props.GetEnv(); // then Assert.AreEqual("RELEASE_CLOUD_URL", host); Assert.AreEqual("ENV", env); }
public void TestReadCloudPropsWithJsonContainingValues() { // given var json = JObject.Parse(@"{ 'url': 'URL', 'hosts': {'host': 'HOST', 'environment': 'ENV'} }"); var config = new FHConfig(new MockDeviceService()); var props = new CloudProps(json, config); // when var host = props.GetCloudHost(); var env = props.GetEnv(); // then Assert.AreEqual("URL", host); Assert.AreEqual("ENV", env); }
/// <summary> /// Constructor /// </summary> /// <param name="cloudProps"></param> public FHActRequest(CloudProps cloudProps) { _cloudProps = cloudProps; }
/// <summary> /// Constructor /// </summary> public FHAuthRequest(CloudProps cloudProps) { _cloudProps = cloudProps; _oauthClient = ServiceFinder.Resolve<IOAuthClientHandlerService>(); }
/// <summary> /// Constructor /// </summary> public FHAuthRequest(CloudProps cloudProps) : base() { this.cloudProps = cloudProps; this.oauthClient = ServiceFinder.Resolve<IOAuthClientHandlerService>(); }
/// <summary> /// Constructor /// </summary> /// <param name="cloudProps"></param> public FHActRequest(CloudProps cloudProps) : base() { this.cloudProps = cloudProps; }
/// <summary> /// Constructor /// </summary> public FHAuthRequest(CloudProps cloudProps) { _cloudProps = cloudProps; _oauthClient = ServiceFinder.Resolve <IOAuthClientHandlerService>(); }
/// <summary> /// Constructor /// </summary> /// <param name="props">The cloud host info</param> public FHCloudRequest(CloudProps props) { RequestPath = ""; _cloudProps = props; }