public async Task Test_GoogleController_NoAPIKey_Fail()
        {
            //Arrange

            //API Key absent
            GoogleAuthModel facebookAuthModel = new GoogleAuthModel
            {
                AuthorizationCode = "<auth_code>"
            };

            GoogleClient client = new GoogleClient(this.SecuritySettings, this.MockHttpClient.Object);

            GoogleAuthenticator authenticator = new GoogleAuthenticator(this.SecuritySettings.GoogleSecuritySettings,
                                                                        client);

            var controller = new GoogleController(authenticator);

            try
            {
                //Act
                var result = await controller.Create(facebookAuthModel);
            }
            catch (SecurityException)
            {
                //Assert
                this.MockGoogleClient.Verify(x => x.PostSecurityRequest(facebookAuthModel), Times.Never);
            }
        }
        public async Task Test_GoogleController_NoAuthorizationCode_Fail()
        {
            //Arrange

            //Authorization Code absent
            GoogleAuthModel googleAuthModel = new GoogleAuthModel
            {
                APIKey = "<api key>"
            };

            GoogleClient client = new GoogleClient(this.SecuritySettings, this.MockHttpClient.Object);

            GoogleAuthenticator authenticator = new GoogleAuthenticator(this.SecuritySettings.GoogleSecuritySettings,
                                                                        client);

            var controller = new GoogleController(authenticator);

            try
            {
                //Act
                var result = await controller.Create(googleAuthModel);
            }
            catch (SecurityException ex)
            {
                //Assert
                Assert.IsType <SecurityException>(ex);
                this.MockGoogleClient.Verify(x => x.PostSecurityRequest(googleAuthModel), Times.Never);
            }
        }
        public async Task Test_GoogleController_GoogleAuth_Fail()
        {
            //Arrange

            //Google Client returns IsAuthenticated false
            this.MockGoogleClient = this.InitMockGoogleClient(this.SecuritySettings, false);

            GoogleAuthModel facebookAuthModel = new GoogleAuthModel
            {
                APIKey            = "<api key>",
                AuthorizationCode = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            };

            GoogleAuthenticator authenticator = new GoogleAuthenticator(this.SecuritySettings.GoogleSecuritySettings,
                                                                        this.MockGoogleClient.Object);

            var controller = new GoogleController(authenticator);

            //Act
            var result = await controller.Create(facebookAuthModel);

            //Assert
            Assert.IsType <BadRequestResult>(result);
            this.MockGoogleClient.Verify(x => x.PostSecurityRequest(facebookAuthModel), Times.Once);
        }
        public async Task Test_GoogleController_Pass()
        {
            //Arrange
            GoogleAuthModel googleAuthModel = new GoogleAuthModel
            {
                APIKey            = "<api key>",
                AuthorizationCode = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            };

            GoogleClient client = new GoogleClient(this.SecuritySettings, this.MockHttpClient.Object);

            GoogleAuthenticator authenticator = new GoogleAuthenticator(this.SecuritySettings.GoogleSecuritySettings,
                                                                        client);

            var controller = new GoogleController(authenticator);

            //Act
            var result = await controller.Create(googleAuthModel);

            var googleResponse = ((result as ObjectResult).Value as GoogleResponseModel);

            //Assert
            Assert.IsType <ObjectResult>(result);
            Assert.True(googleResponse.AccessToken.IsValidJwtToken());
            this.MockHttpClient.Verify(x => x.SendAsync <GoogleResponseModel>(It.IsAny <HttpRequestMessage>()), Times.Once);
        }
Exemplo n.º 5
0
 private bool _pressingButton;      // Is the user pressing a button? Ignore other input.
 //-----------------------------------------------------------------------------------------------
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else
     {
         Object.Destroy(this);
     }
 }
Exemplo n.º 6
0
        private void btnPost_Click(object sender, EventArgs e)
        {
            GoogleController ctrl = new GoogleController();

            webCtrl.Update();
            if (tbScript.Text.Trim().Length == 0)
            {
                webCtrl.Source = new Uri("https://plus.google.com/communities/103386775708787324155");
            }
            else
            {
                JSValue cookie = webCtrl.ExecuteJavascriptWithResult("document.cookie");

                //var javascript = @"document.querySelectorAll('div[data-itemid^=\'update\']>div')[1].click()";
                ctrl.ExecuteScript(webCtrl, tbScript.Text.Trim());
                //string result = ctrl.JsFireEvent(webCtrl, javascript, "click");
            }

            //ctrl.GetAllPosts(webCtrl);
        }
Exemplo n.º 7
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            //webCtrl.Source = new Uri("https://plus.google.com/");
            //webCtrl.Source = new Uri("https://www.google.com");
            //Task t = new Task(() =>
            //{

            //    WebCore.Initialize(new WebConfig(), true);
            //    WebView browser = WebCore.CreateWebView(1024, 768, WebViewType.Offscreen);
            //    browser.DocumentReady += Browser_DocumentReady;
            //    browser.Source = new Uri("https://www.google.ru/");

            //    webCtrl = new WebControl();
            //    tableLayoutPanel1.Controls.Add(browser);
            //    WebCore.Run();
            //});
            //t.Start();
            GoogleController ctrl = new GoogleController();

            ctrl.GetAuthCode(webCtrl);
            Console.WriteLine("done");
        }
Exemplo n.º 8
0
        public void PesquisaGoogle()
        {
            GoogleController.SetInputGoogle("UniBrasil");

            GoogleController.ClickOpcaoUniBrasil();
        }
 private void Awake()
 {
     google = this;
     GetStatus();
 }
        /// <summary>
        /// Search for posts from the pre defined social networks
        /// </summary>
        /// <param name="fetchPoints">List of social network names</param>
        public List <Package> SearchSocialFeeds()
        {
            List <Package> lstPackage = new List <Package>();

            if (fetchPoints != null && fetchPoints.Length > 0)
            {
                bool filterAll = false;
                if (fetchPoints.Length > 1)
                {
                    filterAll = true;
                }
                Parallel.ForEach(fetchPoints, point =>
                {
                    switch (point.ToLower())
                    {
                    case "twitter":

                        // FETCH SETTINGS
                        string consumerKey       = "Iy8lNm4Ey9OmDXAoalt4EksNT";
                        string consumerSecret    = "2b840eCjpc5CDeqxPpTTjmYUSenJyWlVtKR7vcP5jlb667WjVx";
                        string accessToken       = "772764625700057088-YXP2cA913WQXXcuq7OyyT4skSNRNKZE";
                        string accessTokenSecret = "uimffz1YNaXWrIcs8VyogxtomVgUyxO7s6gYxG3SiQto7";

                        TwitterController twitterController = new TwitterController(consumerKey, consumerSecret, accessToken, accessTokenSecret);
                        List <object> lst = twitterController.SearchTwitter(new Entities.QueryInfo()
                        {
                            Containing      = new string[] { "obama", "hillary", "donald" },
                            NotContaining   = new string[] { "election", "whitehouse" },
                            HashTags        = new string[] { "#oabama", "#hillary" },
                            Emoticons       = null,//new string[] { ":)", ":(", "?" };
                            IncludeRetweets = true,
                            SearchCount     = 15,
                            ResultType      = "popular",
                            LanguageCode    = "en",
                            WrittenIn       = "en"
                        }, filterAll);
                        lock (lockable)
                        {
                            lstPackage.Add(new Package()
                            {
                                key          = point.ToLower(),
                                SearchResult = lst
                            });
                        }
                        break;

                    case "google":
                        string apiKey = "AIzaSyAzmIwh3Tq79Yy70eL0RbJBmOS9-MP5uL8";
                        GoogleController googleController = new GoogleController(apiKey);

                        List <object> lstGoogleResponse = googleController.SearchGoogle(new Entities.GoogleSearchInfo()
                        {
                            LanguageCode     = "en",
                            OrderBy          = "best",
                            SearchCount      = 10,
                            SearchParameters = new string[] { "obama", "clinton" }
                        }, filterAll);
                        lock (lockable)
                        {
                            lstPackage.Add(new Package()
                            {
                                key          = point.ToLower(),
                                SearchResult = lstGoogleResponse
                            });
                        }
                        break;

                    default:
                        break;
                    }
                });
            }

            return(lstPackage);
        }