diff --git a/pom.xml b/pom.xml index 4b84d024..25de2cff 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ api jar ${project.groupId}:${project.artifactId} - 3.4.26 + 3.4.27 Hygieia Rest API Layer https://github.com/Hygieia/api diff --git a/src/main/java/com/capitalone/dashboard/webhook/github/GitHubCommitV3.java b/src/main/java/com/capitalone/dashboard/webhook/github/GitHubCommitV3.java index 327c068b..117fe4ae 100644 --- a/src/main/java/com/capitalone/dashboard/webhook/github/GitHubCommitV3.java +++ b/src/main/java/com/capitalone/dashboard/webhook/github/GitHubCommitV3.java @@ -188,6 +188,8 @@ protected List getCommits(List commitListPayload, String repoUrl, String authorLDAPDN = restClient.getString(senderObj, "ldap_dn"); if (!StringUtils.isEmpty(authorLDAPDN)) { commit.setScmAuthorLDAPDN(authorLDAPDN); + } else { + commit.setScmAuthorLDAPDN(getLDAPDN(repoUrl, authorLogin, gitHubWebHookToken)); } } else { long start = System.currentTimeMillis(); @@ -206,7 +208,7 @@ protected List getCommits(List commitListPayload, String repoUrl, } // if ldap dn is null set it from ldapMap if(StringUtils.isEmpty(commit.getScmAuthorLDAPDN())){ - commit.setScmAuthorLDAPDN(getLDAPDN(repoUrl, StringUtils.isEmpty(scmAuthorName) ? authorLogin : scmAuthorName, gitHubWebHookToken)); + commit.setScmAuthorLDAPDN(getLDAPDN(repoUrl, authorLogin, gitHubWebHookToken)); } // Set the Committer details. This in the case of a merge commit is the user who merges the PR. // In the case of a regular commit, it is usually set to a default "name": "GitHub Enterprise", and login is null diff --git a/src/main/java/com/capitalone/dashboard/webhook/github/GitHubPullRequestV3.java b/src/main/java/com/capitalone/dashboard/webhook/github/GitHubPullRequestV3.java index 938b2ba6..cef9ba14 100644 --- a/src/main/java/com/capitalone/dashboard/webhook/github/GitHubPullRequestV3.java +++ b/src/main/java/com/capitalone/dashboard/webhook/github/GitHubPullRequestV3.java @@ -431,7 +431,7 @@ protected List getPRCommits(String repoUrl, Object commitsObject, GitReq if (!StringUtils.isEmpty(authorType)) { newCommit.setScmAuthorType(authorType); } - String authorLDAPDN = getLDAPDN(repoUrl, StringUtils.isEmpty(scmAuthorName) ? newCommit.getScmAuthorLogin() : scmAuthorName, token); + String authorLDAPDN = getLDAPDN(repoUrl, newCommit.getScmAuthorLogin(), token); if (!StringUtils.isEmpty(authorLDAPDN)) { newCommit.setScmAuthorLDAPDN(authorLDAPDN); } diff --git a/src/main/java/com/capitalone/dashboard/webhook/github/GitHubV3.java b/src/main/java/com/capitalone/dashboard/webhook/github/GitHubV3.java index ef29bf6f..c028fda8 100644 --- a/src/main/java/com/capitalone/dashboard/webhook/github/GitHubV3.java +++ b/src/main/java/com/capitalone/dashboard/webhook/github/GitHubV3.java @@ -190,16 +190,6 @@ protected void getUser(String repoUrl, String user, String token) { String formattedUser = user.replace("_", "-"); int retryCount = 0; ResponseEntity response; - - if(apiSettings.isOptimizeUserCallsToGithub()) { - UserEntitlements entitlements = userEntitlementsRepository.findTopByAuthTypeAndEntitlementTypeAndUsername(AuthType.LDAP, - ENTITLEMENT_TYPE, StringUtils.lowerCase(user)); - String ldapDN = (entitlements == null) ? "" : entitlements.getEntitlements(); - ldapMap.put(user, ldapDN); - authorTypeMap.put(user, "User"); - return; - } - while(true) { try { long start = System.currentTimeMillis(); @@ -239,7 +229,9 @@ protected String getLDAPDN(String repoUrl, String user, String token) { if (ldapMap == null) { ldapMap = new HashMap<>(); } if(apiSettings.isOptimizeUserCallsToGithub()) { - return ldapMap.get(user); + UserEntitlements entitlements = userEntitlementsRepository.findTopByAuthTypeAndEntitlementTypeAndUsername(AuthType.LDAP, + ENTITLEMENT_TYPE, StringUtils.lowerCase(user)); + return (entitlements == null) ? "" : entitlements.getEntitlements(); } //This is weird. Github does replace the _ in commit author with - in the user api!!!