Used to connect to the Github repos
Inheritance: IGithubClient
        public void GithubClient_GetRepositories_CredentialsFail()
        {
            var helper = new Mock<IWebsiteRequestHelper>();
            //helper.Setup(a => a.GetStringResponse(null, null, null))

            var client = new GithubClient(helper.Object);

            client.GetRepositories();
        }
 public void GithubClient_GetRepositories_JsonFormatFail()
 {
     var helper = new Mock<IWebsiteRequestHelper>();
     helper.Setup(a => a.GetStringResponse("azurecoder", "adghjsueu374", "blah"))
           .Returns(JsonResponseIncorrect);
     var client = new GithubClient(helper.Object)
                      {
                          Username = "******",
                          Password = "******"
                      };
     var list = client.GetRepositories("blah");
 }
 public void GithubClient_GetRepositories_List()
 {
     var helper = new Mock<IWebsiteRequestHelper>();
     helper.Setup(a => a.GetStringResponse("azurecoder", "adghjsueu374", "blah"))
           .Returns(JsonResponseCorrect);
     var client = new GithubClient(helper.Object)
     {
         Username = "******",
         Password = "******"
     };
     var list = client.GetRepositories("blah");
     list.Count.Should().Be(5);
     list["b"].Should().Be("a");
 }
        /// <summary>
        /// Creates a website given github credentials
        /// </summary>
        /// <param name="website"></param>
        /// <param name="gitDetails">the details of the github repo</param>
        public void CreateFromGithub(Website website, GitDetails gitDetails)
        {
            // create the new website
            Create(website);

            // we have the new website properties
            var githubClient = new GithubClient(new WebsiteRequestHelper())
            {
                Username = gitDetails.Username,
                Password = gitDetails.Password,
            };
            var repoList = githubClient.GetRepositories();

            if (!repoList.ContainsKey(gitDetails.RepositoryName))
            {
                throw new FluentManagementException("git repository not found", "WebsiteClient");
            }
            // add the service hook in place
            string setServiceHook = githubClient.SetServiceHook(WebsiteProperties.Config.PublishingUsername,
                                                                WebsiteProperties.Config.PublishingPassword, website.Name + ".scm.azurewebsites.net",
                                                                repoList[gitDetails.RepositoryName], gitDetails.RepositoryName);

            // get all of the auth token values
            githubClient.GetOAuthToken(repoList[gitDetails.RepositoryName], gitDetails.RepositoryName);
            // add the metadata from the service hook
            WebsiteProperties.Config.Metadata.Add("ScmUri", githubClient.ScmUri);
            WebsiteProperties.Config.Metadata.Add("CloneUri", githubClient.CloneUri);
            WebsiteProperties.Config.Metadata.Add("RepoApiUri", githubClient.RepoApiUri);
            WebsiteProperties.Config.Metadata.Add("OAuthToken", githubClient.OAuthToken);
            WebsiteProperties.Config.ScmType = ScmType.GitHub;
            // update windows azure
            Update();
            // call the service hook
            //githubClient.TestServiceHook(setServiceHook);
            if (!String.IsNullOrEmpty(setServiceHook))
            {
                return;
            }
            Delete();
            throw new FluentManagementException(
                      "website created but unable to set service hook in github rolled back deployment", "WebsiteClient");
        }
        /// <summary>
        /// Creates a website given github credentials
        /// </summary>
        /// <param name="website"></param>
        /// <param name="gitDetails">the details of the github repo</param>
        public void CreateFromGithub(Website website, GitDetails gitDetails)
        {
            // create the new website
            Create(website);

            // we have the new website properties
            var githubClient = new GithubClient(new WebsiteRequestHelper())
                                   {
                                       Username = gitDetails.Username,
                                       Password = gitDetails.Password,
                                   };
            var repoList = githubClient.GetRepositories();
            if(!repoList.ContainsKey(gitDetails.RepositoryName))
                throw new FluentManagementException("git repository not found", "WebsiteClient");
            // add the service hook in place
            string setServiceHook = githubClient.SetServiceHook(WebsiteProperties.Config.PublishingUsername,
                                        WebsiteProperties.Config.PublishingPassword, website.Name + ".scm.azurewebsites.net",
                                        repoList[gitDetails.RepositoryName], gitDetails.RepositoryName);

            // get all of the auth token values
            githubClient.GetOAuthToken(repoList[gitDetails.RepositoryName], gitDetails.RepositoryName);
            // add the metadata from the service hook
            WebsiteProperties.Config.Metadata.Add("ScmUri", githubClient.ScmUri);
            WebsiteProperties.Config.Metadata.Add("CloneUri", githubClient.CloneUri);
            WebsiteProperties.Config.Metadata.Add("RepoApiUri", githubClient.RepoApiUri);
            WebsiteProperties.Config.Metadata.Add("OAuthToken", githubClient.OAuthToken);
            WebsiteProperties.Config.ScmType = ScmType.GitHub;
            // update windows azure
            Update();
            // call the service hook
            //githubClient.TestServiceHook(setServiceHook);
            if (!String.IsNullOrEmpty(setServiceHook)) return;
            Delete();
            throw new FluentManagementException(
                "website created but unable to set service hook in github rolled back deployment", "WebsiteClient");
        }