Exemplo n.º 1
0
 public JiraConnector(IJiraConfiguration jiraConfiguration, JiraMonitor jiraMonitor)
 {
     jiraConfiguration.Url = jiraConfiguration.Url.Replace(DefaultPostfix, "");
     _jiraConfiguration    = jiraConfiguration;
     _jiraMonitor          = jiraMonitor;
     _jiraClient           = JiraClient.Create(new Uri(jiraConfiguration.Url));
 }
Exemplo n.º 2
0
 public void Connect(IJiraClient client)
 {
     _client    = client;
     Fields     = _client.GetFields();
     IssueTypes = _client.GetIssueTypes();
     Priorities = _client.GetPriorities();
 }
Exemplo n.º 3
0
 public void ReConnect(IJiraConnectionSettings newJiraConnectionSettings, IExportSettings newExportSettings)
 {
     exportSettings         = newExportSettings;
     jiraConnectionSettings = newJiraConnectionSettings;
     jira = null;
     CheckAndConnectJira();
     UpdateJiraProjectCache();
 }
Exemplo n.º 4
0
 public void ReConnect(IJiraConnectionSettings newJiraConnectionSettings, IExportSettings newExportSettings)
 {
     exportSettings         = newExportSettings;
     jiraConnectionSettings = newJiraConnectionSettings;
     jira = null;
     CheckAndConnectJira();
     Task.Factory.StartNew(UpdateJiraProjectCache);
 }
Exemplo n.º 5
0
 /// <summary>
 ///     Override the BeginProcessingAsync to connect to our jira
 /// </summary>
 protected override Task BeginProcessingAsync()
 {
     JiraApi = JiraClient.Create(JiraUri);
     if (Username != null)
     {
         JiraApi.SetBasicAuthentication(Username, Password);
     }
     return(Task.FromResult(true));
 }
Exemplo n.º 6
0
 public PresentationsController(
     IJiraClient jiraClient,
     IDbClient dbClient,
     ILdapClient ldapClient
     )
 {
     this.jiraClient = jiraClient;
     this.dbClient   = dbClient;
     this.ldapClient = ldapClient;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Creates a JIRA client with service dependency.
 /// </summary>
 public static Jira CreateRestClient(IJiraClient jiraClient, JiraCredentials credentials = null, JiraCache cache = null)
 {
     return(new Jira(
                new JqlExpressionVisitor(),
                jiraClient,
                new FileSystem(),
                credentials,
                null,
                cache));
 }
Exemplo n.º 8
0
        public JiraClientTests()
        {
            _jiraClientWrapperMock      = new Mock <IJiraClientWrapper>();
            _issueServiceMock           = new Mock <IIssueService>();
            _classThatWeActuallyTesting = new JiraClient(_jiraClientWrapperMock.Object);

            var client = CreateRestClient("https://your_jira_address/");
            var fields = new CreateIssueFields(ProjectNames[0]);

            _myIssue = new Issue(client, fields);
        }
Exemplo n.º 9
0
 public JiraConnector(
     IJiraConfiguration jiraConfiguration,
     JiraMonitor jiraMonitor,
     ICoreConfiguration coreConfiguration,
     INetworkConfiguration networkConfiguration)
 {
     jiraConfiguration.Url = jiraConfiguration.Url.Replace(DefaultPostfix, "");
     _jiraConfiguration    = jiraConfiguration;
     _jiraMonitor          = jiraMonitor;
     _coreConfiguration    = coreConfiguration;
     _jiraClient           = JiraClient.Create(new Uri(jiraConfiguration.Url), networkConfiguration);
 }
Exemplo n.º 10
0
 public SampleDataController(
     IMemoryCache cache,
     IJiraClient jiraClient,
     IBoardCreator boardCreator,
     IDbClient dbClient
     )
 {
     this.jiraClient   = jiraClient;
     this.cache        = cache;
     this.boardCreator = boardCreator;
     this.dbClient     = dbClient;
 }
Exemplo n.º 11
0
        private void CheckAndConnectJira(bool useRestApi = true)
        {
            if (jira == null)
            {
                if (string.IsNullOrWhiteSpace(jiraConnectionSettings.JiraUrl) ||
                    string.IsNullOrWhiteSpace(jiraConnectionSettings.JiraUsername) ||
                    string.IsNullOrWhiteSpace(jiraConnectionSettings.JiraPassword))
                {
                    throw new MissingJiraConfigException("Required settings to create connection to jira are missing");
                }

                try
                {
                    var url = jiraConnectionSettings.JiraUrl.Replace("/secure/Dashboard.jspa", "");

                    if (useRestApi)
                    {
                        jira = new JiraRestClient(url, jiraConnectionSettings.JiraUsername, jiraConnectionSettings.JiraPassword);
                    }
                    else
                    {
                        jira = new JiraSoapClient(url, jiraConnectionSettings.JiraUsername, jiraConnectionSettings.JiraPassword);
                    }

                    CurrentUser = jira.GetCurrentUser();

                    TrackingType trackingType;
                    if (useRestApi)
                    {
                        trackingType = url.Contains(".atlassian.net") ? TrackingType.JiraConnectCloudRest : TrackingType.JiraConnectSelfhostRest;
                    }
                    else
                    {
                        trackingType = url.Contains(".atlassian.net") ? TrackingType.JiraConnectCloudSoap : TrackingType.JiraConnectSelfhostSoap;
                    }

                    trackUsage.TrackAppUsage(trackingType);
                }
                catch (Exception ex)
                {
                    jira = null;
                    if (useRestApi)
                    {
                        CheckAndConnectJira(false);
                    }
                    else
                    {
                        throw new JiraConnectionException("Error creating instance of Jira", ex);
                    }
                }
            }
        }
        public async Task Test_GetIssueLinkTypes_Async()
        {
            // Create the client.
            IJiraClient client = CreateJiraClient();

            // Make the call.
            GetIssueLinkTypesResponse response = await client
                                                 .GetIssueLinkTypesAsync(CancellationToken.None)
                                                 .ConfigureAwait(false);

            // Assert.
            Assert.NotEmpty(response.IssueLinkTypes);
        }
Exemplo n.º 13
0
 public JiraJob(
     ILogger <JiraJob> logger,
     IElasticsearchClient elasticsearchClient,
     IApplicationPropertyDao applicationPropertyDao,
     IJiraClient jiraClient,
     IOptions <JiraSettings> settings)
 {
     _logger = logger;
     _elasticsearchClient    = elasticsearchClient;
     _applicationPropertyDao = applicationPropertyDao;
     _jiraClient             = jiraClient;
     _settings = settings;
 }
Exemplo n.º 14
0
        public TriageService(string nickname, string password, string jiraUri, ICheckLogService checkLogService, IMapper mapper)
        {
            _checkLogService = checkLogService;
            _mapper          = mapper;
            _client          = new JiraClient.JiraClient(new Uri(jiraUri));
            _client.SetBasicAuthentication(nickname, password);

            _impededIssueTypes = new List <string>()
            {
                "ON HOLD",
                "DEVELOPMENT IMPEDED",
                "TESTING IMPEDED"
            };
        }
Exemplo n.º 15
0
        /// <summary>
        /// Add an instance of a JIRA system
        /// </summary>
        /// <param name="jiraInstance"></param>
        /// <param name="token"></param>
        public async Task AddJiraInstanceAsync(IJiraClient jiraInstance, CancellationToken token = default(CancellationToken))
        {
            _jiraInstances.Add(jiraInstance);
            var projects = await jiraInstance.Project.GetAllAsync(cancellationToken : token).ConfigureAwait(false);

            if (projects != null)
            {
                foreach (var project in projects)
                {
                    if (!_projectJiraClientMap.ContainsKey(project.Key))
                    {
                        _projectJiraClientMap.Add(project.Key, jiraInstance);
                    }
                }
            }
        }
Exemplo n.º 16
0
        public async Task Update(IJiraClient client, DateTime startUpdateDate, string projectKey, ICacheUpdateProgress progress = null)
        {
            await EnsureInitialized();

            progress = progress ?? new NullCacheUpdateProgres();

            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (string.IsNullOrWhiteSpace(projectKey))
            {
                throw new ArgumentNullException(nameof(projectKey));
            }

            DateTime lastUpdateDate = await GetLastUpdateDateTime(projectKey, startUpdateDate);

            int itemPaging = 0;

            while (true)
            {
                const int queryLimit = 50;

                IJiraIssue[] updatedIssues = await client.GetIssues(projectKey, lastUpdateDate, queryLimit, itemPaging);

                foreach (var issue in updatedIssues)
                {
                    CachedIssue flatIssue = await client.RetrieveDetails(issue);

                    await _repository.AddOrReplaceCachedIssue(flatIssue);

                    progress.UpdatedIssue(flatIssue.Key, flatIssue.Updated.Value);
                }

                itemPaging += queryLimit;

                if (updatedIssues.Length != queryLimit)
                {
                    break;
                }
            }
        }
Exemplo n.º 17
0
        public OAuthTests(ITestOutputHelper testOutputHelper)
        {
            // A demo Private key, to create a RSACryptoServiceProvider.
            // This was created from a .pem via a tool here http://www.jensign.com/opensslkey/index.html
            const string privateKeyXml = @"<RSAKeyValue><Modulus>tGIwsCH2KKa6vxUDupW92rF68S5SRbgr7Yp0xeadBsb0BruTt4GMrVL7QtiZWM8qUkY1ccMa7LkXD93uuNUnQEsH65s8ryID9P
DeEtCBcxFEZFdcKfyKR+5B+NRLW5lJq10sHzWbJ0EROUmEjoYfi3CtsMkJHYHDL9dZeCqAZHM=</Modulus><Exponent>AQAB</Exponent><P>14DdDg26
CrLhAFQIQLT1KrKVPYr0Wusi2ovZApz2/RnM7a7CWUJuDR3ClW5g9hdi+KQ0ceD5oJYX5Vexv2uk+w==</P><Q>1kfU0+DkXc6I/jXHJ6pDLA5s7dBHzWgDs
BzplSdkVQbKT3MbeYjeByOxzXhulOWLBQW/vxmW4HwU95KTRlj06Q==</Q><DP>SPoBYY3yb0cN/J94P/lHgJMDCNkyUEuJ/PoYndLrrN/8zow8kh91xwlJ6
HJ9cTiQMmTgwaOOxPuu0eI1df4M2w==</DP><DQ>klJaspRPXP877NssM5nAZMU0/O/NGCZ+3jPgDUno6WbJn5cqm8MqWhW1xGkImgRk+fkDBquiq4gPiT89
8jusgQ==</DQ><InverseQ>d5Zrr6Q8AO/0isr/3aa6O6NLQxISLKcPDk2NOccAfS/xOtfOz4sJYM3+Bs4Io9+dZGSDCA54Lw03eHTNQghS0A==</Inverse
Q><D>WFlbZXlM2r5G6z48tE+RTKLvB1/btgAtq8vLw/5e3KnnbcDD6fZO07m4DRaPjRryrJdsp8qazmUdcY0O1oK4FQfpprknDjP+R1XHhbhkQ4WEwjmxPst
ZMUZaDWF58d3otc23mCzwh3YcUWFu09KnMpzZsK59OfyjtkS44EDWpbE=</D></RSAKeyValue>";

            // Create the RSACryptoServiceProvider for the XML above
            var rsaCryptoServiceProvider = new RSACryptoServiceProvider();

            rsaCryptoServiceProvider.FromXmlString(privateKeyXml);

            // Configure the XUnitLogger for logging
            LogSettings.RegisterDefaultLogger <XUnitLogger>(LogLevels.Verbose, testOutputHelper);

            // Only a few settings for the Jira OAuth are important
            var oAuthSettings = new JiraOAuthSettings
            {
                // Is specified on the linked-applications as consumer key
                ConsumerKey = "lInXLgx6HbF9FFq1ZQN8iSEnhzO3JVuf",
                // This needs to have the private key, the represented public key is set in the linked-applications
                RsaSha1Provider = rsaCryptoServiceProvider,
                // Use a server at Localhost to redirect to, alternative an embedded browser can be used
                AuthorizeMode = AuthorizeModes.LocalhostServer,
                // When using the embbed browser this is directly visible, with the LocalhostServer it's in the info notice after a redirect
                CloudServiceName = "Greenshot Jira",
                // the IOAuth1Token implementation, here it's this, gets the tokens to store & retrieve for later
                Token = this
            };

            // Create the JiraApi for the Uri and the settings
            _jiraApi = OAuthJiraClient.Create(TestJiraUri, oAuthSettings);
        }
Exemplo n.º 18
0
        private void CheckAndConnectJira(bool useRestApi = true)
        {
            if (jira == null)
            {
                if (string.IsNullOrWhiteSpace(jiraConnectionSettings.JiraUrl) ||
                    string.IsNullOrWhiteSpace(jiraConnectionSettings.JiraUsername) ||
                    string.IsNullOrWhiteSpace(jiraConnectionSettings.JiraPassword))
                {
                    throw new MissingJiraConfigException("Required settings to create connection to jira are missing");
                }

                try
                {
                    if (useRestApi)
                    {
                        jira = new JiraRestClient(jiraConnectionSettings.JiraUrl.Replace("/secure/Dashboard.jspa", ""), jiraConnectionSettings.JiraUsername, jiraConnectionSettings.JiraPassword);
                    }
                    else
                    {
                        jira = new JiraSoapClient(jiraConnectionSettings.JiraUrl.Replace("/secure/Dashboard.jspa", ""), jiraConnectionSettings.JiraUsername, jiraConnectionSettings.JiraPassword);
                    }

                    CurrentUser = jira.GetCurrentUser();
                }
                catch (Exception ex)
                {
                    jira = null;
                    if (useRestApi)
                    {
                        CheckAndConnectJira(false);
                    }
                    else
                    {
                        throw new JiraConnectionException("Error creating instance of Jira", ex);
                    }
                }
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Internal login which catches the exceptions
        /// </summary>
        /// <returns>true if login was done sucessfully</returns>
        private async Task <bool> DoLoginAsync(string user, string password, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(password))
            {
                return(false);
            }
            _jiraClient = JiraClient.Create(new Uri(JiraConfig.Url));
            _jiraClient.Behaviour.SetConfig(new SvgConfiguration {
                Width = CoreConfig.IconSize.Width, Height = CoreConfig.IconSize.Height
            });

            _issueTypeBitmapCache = new IssueTypeBitmapCache(_jiraClient);
            LoginInfo loginInfo;

            try
            {
                loginInfo = await _jiraClient.Session.StartAsync(user, password, cancellationToken);

                Monitor = new JiraMonitor();
                await Monitor.AddJiraInstanceAsync(_jiraClient, cancellationToken);

                var favIconUri = _jiraClient.JiraBaseUri.AppendSegments("favicon.ico");
                try
                {
                    FavIcon = await _jiraClient.Server.GetUriContentAsync <Bitmap>(favIconUri, cancellationToken);
                }
                catch (Exception ex)
                {
                    Log.WarnFormat("Couldn't load favicon from {0}", favIconUri);
                    Log.Warn("Exception details: ", ex);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(loginInfo != null);
        }
Exemplo n.º 20
0
        private void CheckAndConnectJira()
        {
            if (jira == null)
            {
                try
                {
                    jira = JiraClientFactory.BuildJiraClient(jiraConnectionSettings.JiraUrl, jiraConnectionSettings.JiraUsername, jiraConnectionSettings.JiraPassword, jiraConnectionSettings.UseTempo);

                    CurrentUser = jira.GetCurrentUser();
                    LoggedIn?.Invoke(this, null);

                    TrackingType trackingType;
                    if (jira.GetType() == typeof(JiraRestClient) && jira.HasTempo)
                    {
                        trackingType = jiraConnectionSettings.JiraUrl.Contains(".atlassian.net") ? TrackingType.JiraConnectCloudRestWithTempo : TrackingType.JiraConnectSelfhostRestWithTempo;
                    }
                    else if (jira.GetType() == typeof(JiraRestClient))
                    {
                        trackingType = jiraConnectionSettings.JiraUrl.Contains(".atlassian.net") ? TrackingType.JiraConnectCloudRest : TrackingType.JiraConnectSelfhostRest;
                    }
                    else
                    {
                        trackingType = jiraConnectionSettings.JiraUrl.Contains(".atlassian.net") ? TrackingType.JiraConnectCloudSoap : TrackingType.JiraConnectSelfhostSoap;
                    }

                    trackUsage.TrackAppUsage(trackingType);
                }
                catch (InvalidCredentialException)
                {
                    throw new MissingJiraConfigException("Required settings to create connection to jira are missing");
                }
                catch (Exception ex)
                {
                    throw new JiraConnectionException("Error creating instance of Jira", ex);
                }
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// Specify the IJiraClient used to perform certain actions with
 /// </summary>
 /// <param name="jiraClient"></param>
 /// <returns>IssueBase (this)</returns>
 public IssueBase WithClient(IJiraClient jiraClient)
 {
     AssociatedJiraClient = jiraClient;
     return(this);
 }
Exemplo n.º 22
0
 public BoardCreator(IJiraClient jiraClient)
 {
     this.jiraClient = jiraClient;
 }
Exemplo n.º 23
0
 public JiraClient(string baseUrl, string username, string password)
 {
     this.client = new JiraClient <IssueFields>(baseUrl, username, password);
 }
Exemplo n.º 24
0
 public void ReConnect(IJiraConnectionSettings newJiraConnectionSettings, IExportSettings newExportSettings)
 {
     exportSettings = newExportSettings;
     jiraConnectionSettings = newJiraConnectionSettings;
     jira = null;
     CheckAndConnectJira();
     Task.Factory.StartNew(UpdateJiraProjectCache);
 }
Exemplo n.º 25
0
 public HomeController(IJiraClient jiraClient, IReportService reportService, ReportSetup defaultReportSetup)
 {
     _jiraClient = jiraClient;
     _reportService = reportService;
     _defaultReportSetup = defaultReportSetup;
 }
Exemplo n.º 26
0
 public void Connect(IJiraClient client)
 {
     _client = client;
     Fields  = _client.GetFields();
 }
Exemplo n.º 27
0
 public JiraRestService(string instance, string username, string password)
 {
     _username = username;
     _jira     = new JiraClient <IssueFields>(instance, username, password);
 }
Exemplo n.º 28
0
 public void ReConnect(IJiraConnectionSettings newJiraConnectionSettings, IExportSettings newExportSettings)
 {
     exportSettings = newExportSettings;
     jiraConnectionSettings = newJiraConnectionSettings;
     jira = null;
     CheckAndConnectJira();
     UpdateJiraProjectCache();
 }
Exemplo n.º 29
0
        private void CheckAndConnectJira(bool useRestApi = true)
        {
            if (jira == null)
            {
                if (string.IsNullOrWhiteSpace(jiraConnectionSettings.JiraUrl) ||
                    string.IsNullOrWhiteSpace(jiraConnectionSettings.JiraUsername) ||
                    string.IsNullOrWhiteSpace(jiraConnectionSettings.JiraPassword))
                {
                    throw new MissingJiraConfigException("Required settings to create connection to jira are missing");
                }

                try
                {
                    if (useRestApi)
                    {
                        jira = new JiraRestClient(jiraConnectionSettings.JiraUrl.Replace("/secure/Dashboard.jspa", ""), jiraConnectionSettings.JiraUsername, jiraConnectionSettings.JiraPassword);
                    }
                    else
                    {
                        jira = new JiraSoapClient(jiraConnectionSettings.JiraUrl.Replace("/secure/Dashboard.jspa", ""), jiraConnectionSettings.JiraUsername, jiraConnectionSettings.JiraPassword);
                    }

                    CurrentUser = jira.GetCurrentUser();
                }
                catch (Exception ex)
                {
                    jira = null;
                    if (useRestApi)
                    {
                        CheckAndConnectJira(false);
                    }
                    else
                    {
                        throw new JiraConnectionException("Error creating instance of Jira", ex);
                    }
                }
            }
        }
Exemplo n.º 30
0
 public JiraClient(string baseUrl, string username, string password)
 {
     client = new JiraClient <IssueFields>(baseUrl, username, password);
     client.OnPercentComplete += onPercentComplete;
 }
Exemplo n.º 31
0
 public void SetUp()
 {
     _jiraClientStub = MockRepository.GenerateStub<IJiraClient>();
       _jiraIssueAggregator = new JiraIssueAggregator (_jiraClientStub);
 }
Exemplo n.º 32
0
 public void SetUp()
 {
     _jiraClientStub      = MockRepository.GenerateStub <IJiraClient>();
     _jiraIssueAggregator = new JiraIssueAggregator(_jiraClientStub);
 }
Exemplo n.º 33
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="jiraClient"></param>
 public AvatarCache(IJiraClient jiraClient)
 {
     _jiraClient = jiraClient;
 }
Exemplo n.º 34
0
		public void Connect(IJiraClient client)
		{
			_client = client;
            Fields = _client.GetFields();
		}
Exemplo n.º 35
0
 public void Connect(IJiraClient client)
 {
     _client = client;
 }
Exemplo n.º 36
0
        public JiraIssueAggregator(IJiraClient jiraClient)
        {
            ArgumentUtility.CheckNotNull ("jiraClient", jiraClient);

              _jiraClient = jiraClient;
        }
Exemplo n.º 37
0
        private void CheckAndConnectJira()
        {
            if (jira == null)
            {
                try
                {
                    jira = JiraClientFactory.BuildJiraClient(jiraConnectionSettings.JiraUrl, jiraConnectionSettings.JiraUsername, jiraConnectionSettings.JiraPassword);

                    CurrentUser = jira.GetCurrentUser();
                    LoggedIn?.Invoke(this, null);

                    TrackingType trackingType;
                    if (jira.GetType() == typeof(JiraRestClient))
                    {
                        trackingType = jiraConnectionSettings.JiraUrl.Contains(".atlassian.net") ? TrackingType.JiraConnectCloudRest : TrackingType.JiraConnectSelfhostRest;
                    }
                    else
                    {
                        trackingType = jiraConnectionSettings.JiraUrl.Contains(".atlassian.net") ? TrackingType.JiraConnectCloudSoap : TrackingType.JiraConnectSelfhostSoap;
                    }

                    trackUsage.TrackAppUsage(trackingType);

                }
                catch (InvalidCredentialException)
                {
                    throw new MissingJiraConfigException("Required settings to create connection to jira are missing");
                }
                catch (Exception ex)
                {
                    throw new JiraConnectionException("Error creating instance of Jira", ex);
                }
            }
        }
Exemplo n.º 38
0
 public JiraClient(string baseUrl, string username, string password, string version = "2")
 {
     client = new JiraClient <IssueFields>(baseUrl, username, password, version);
 }