-
Notifications
You must be signed in to change notification settings - Fork 42
Add role mapping actions #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
i11
wants to merge
2
commits into
RiotGamesMinions:master
Choose a base branch
from
i11:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 3.0.0 | ||
| 3.0.1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| require 'json' | ||
|
|
||
| module NexusCli | ||
| # @author Ilja Bobkevic <ilja.bobkevic@gmail.com> | ||
| module LdapActions | ||
|
|
||
| # Set provided LDAP connection information | ||
| # | ||
| # @param params [Hash] a Hash of parameters for connection information | ||
| # | ||
| # @return [Boolean] true if the connection information was set, false otherwise | ||
| def set_ldap_connection_info(params) | ||
| response = nexus.put(nexus_url("service/local/ldap/conn_info"), :body => create_data(params), :header => DEFAULT_CONTENT_TYPE_HEADER) | ||
| case response.status | ||
| when 200 | ||
| return true | ||
| else | ||
| raise UnexpectedStatusCodeException.new(reponse.code) | ||
| end | ||
| end | ||
|
|
||
| # Set provided LDAP user and group configuration | ||
| # | ||
| # @param params [Hash] a Hash of parameters for user and group configuration | ||
| # | ||
| # @return [Boolean] true if the user and group configuration was set, false otherwise | ||
| def set_ldap_user_group_configuration(params) | ||
| response = nexus.put(nexus_url("service/local/ldap/user_group_conf"), :body => create_data(params), :header => DEFAULT_CONTENT_TYPE_HEADER) | ||
| case response.status | ||
| when 200 | ||
| return true | ||
| else | ||
| raise UnexpectedStatusCodeException.new(reponse.code) | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def create_data(params) | ||
| JSON.dump(:data => params) | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| require 'json' | ||
|
|
||
| module NexusCli | ||
| # @author Ilja Bobkevic <ilja.bobkevic@gmail.com> | ||
| module RoleMappingActions | ||
|
|
||
| # Creates a User to role mapping within given source | ||
| # | ||
| # @param params [Hash] a Hash of parameters to use during user to role mapping creation | ||
| # | ||
| # @return [Boolean] true if the user to role mapping is created, false otherwise | ||
| def create_role_mapping(params) | ||
| response = nexus.put(nexus_url("service/local/user_to_roles/#{params[:source]}/#{params[:userId]}"), :body => create_user_json(params), :header => DEFAULT_CONTENT_TYPE_HEADER) | ||
| case response.status | ||
| when 204 | ||
| return true | ||
| when 404 | ||
| raise UserNotFoundException.new(params[:userId]) | ||
| else | ||
| raise UnexpectedStatusCodeException.new(reponse.code) | ||
| end | ||
| end | ||
|
|
||
| # Deletes the Nexus user to role mapping from define source and with the given user id. | ||
| # | ||
| # @param realm [String] the mapping realm, e.g. LDAP | ||
| # @param user_id [String] the Nexus user to role mapping to delete | ||
| # | ||
| # @return [Boolean] true if the user to role mapping is deleted, false otherwise | ||
| def delete_role_mapping(realm, mapping_id) | ||
| response = nexus.delete(nexus_url("service/local/user_to_roles/#{realm}/#{mapping_id}")) | ||
| case response.status | ||
| when 204 | ||
| return true | ||
| when 404 | ||
| raise UserNotFoundException.new(mapping_id) | ||
| else | ||
| raise UnexpectedStatusCodeException.new(response.status) | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def create_user_json(params) | ||
| JSON.dump(:data => params) | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't change this file in pull requests. It will be changed when a new version is released.