Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/meln5674/nexus-oidc-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
meln5674 committed Feb 19, 2024
2 parents 85ded50 + 78a628d commit 98912e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ var (

testUsers = []map[string]interface{}{
{"userId": "user1", "firstName": "user", "lastName": "one", "emailAddress": "[email protected]", "status": "active", "roles": []string{"nx-anonymous"}, "password": "user1Password"},
{"userId": "user12", "firstName": "user", "lastName": "one", "emailAddress": "[email protected]", "status": "active", "roles": []string{"nx-anonymous"}, "password": "user12Password"},
}

testRoles = []map[string]interface{}{
Expand Down
16 changes: 14 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,23 @@ func (p *ProxyState) GetUsers(userID *string) ([]NexusUser, error) {
body, _ := ioutil.ReadAll(res.Body)
return nil, fmt.Errorf("GET %s: %s - %s", &getUser, res.Status, string(body))
}
result := make([]NexusUser, 0, 1)
err = json.NewDecoder(res.Body).Decode(&result)
tmpResult := make([]NexusUser, 0, 1)
err = json.NewDecoder(res.Body).Decode(&tmpResult)
if err != nil {
return nil, err
}
// Nexus API filters results by prefix instead of exact match
// This ensures that the user returned is the user requested by userID variable
result := make([]NexusUser, 0, 1)
if userID != nil {
for _, user := range tmpResult {
if user.UserID == *userID {
result = append(result, user)
}
}
} else {
result = tmpResult
}
if len(result) == 0 {
return nil, nil
}
Expand Down

0 comments on commit 98912e8

Please sign in to comment.