diff --git a/.rubocop.yml b/.rubocop.yml index f25cf2a..819aea2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,8 @@ require: rubocop-performance AllCops: TargetRubyVersion: 2.5 NewCops: enable + Exclude: + - 'test.rb' Layout/LineLength: Max: 123 @@ -41,4 +43,4 @@ Style/OptionalBooleanParameter: Enabled: false Lint/MissingSuper: - Enabled: false \ No newline at end of file + Enabled: false diff --git a/Gemfile b/Gemfile index 8354250..1339295 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,13 @@ source 'https://rubygems.org' # Specify your gem's dependencies in sonarqube.gemspec gemspec +group :development do + gem 'guard' + gem 'guard-bundler', require: false + gem 'guard-rspec', require: false + gem 'guard-rubocop' +end + gem 'pry' gem 'rubocop' gem 'rubocop-performance' diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000..e750813 --- /dev/null +++ b/Guardfile @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +guard :rspec, cmd: 'rspec' do + watch(%r{^spec/.+_spec\.rb$}) + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { 'spec' } +end + +guard :rubocop do + ignore(/{^test.rb}/) + watch(/{.+\.rb$}/) + watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) } +end + +guard :bundler do + require 'guard/bundler' + require 'guard/bundler/verify' + helper = Guard::Bundler::Verify.new + + files = ['Gemfile'] + files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) } + + # Assume files are symlinked from somewhere + files.each { |file| watch(helper.real_path(file)) } +end diff --git a/docs/client/permissions.markdown b/docs/client/permissions.markdown new file mode 100644 index 0000000..3721400 --- /dev/null +++ b/docs/client/permissions.markdown @@ -0,0 +1,174 @@ +--- +layout: default +title: Permissions +nav_order: 5 +parent: Client +--- + +
+ + Table of contents + + {: .text-delta } +1. TOC +{:toc} +
+ +# Permissions + +## Add Permisssion to group +```ruby +['user', 'codeviewer', 'issueadmin', 'securityhotspotadmin', 'scan'].each do | permission | + status = Sonarqube.permissions_add_group({groupName: 'New-Group', permission: permission, projectKey: 'test'}) + status.to_hash.nil? +end +# => true +# => true +# => true +# => true +# => true +``` + +## Add group to template +```ruby +['user', 'codeviewer', 'issueadmin', 'securityhotspotadmin', 'scan'].each do | permission | + status = Sonarqube.add_group_to_template({groupName: 'New-Group', permission: permission, templateName: 'test'}) + status.to_hash.nil? +end +# => true +# => true +# => true +# => true +# => true +``` + +## Add project creator to template +```ruby +['user', 'codeviewer', 'issueadmin', 'securityhotspotadmin', 'scan'].each do | permission | + status = Sonarqube.add_project_creator_to_template(permission, { templateName: 'test' }) + status.to_hash.nil? +end +# => true +# => true +# => true +# => true +# => true +``` + +## Add permissions to user +```ruby +['user', 'codeviewer', 'issueadmin', 'securityhotspotadmin', 'scan'].each do | permission | + status = permission_add_user('user', permission, { templateName: 'test' }) + status.to_hash.nil? +end +# => true +# => true +# => true +# => true +# => true +``` + +## Add user to template +```ruby +['user', 'codeviewer', 'issueadmin', 'securityhotspotadmin', 'scan'].each do | permission | + status = Sonarqube.add_user_to_template({ login: 'new_user', permission: 'user', templateName: 'test' }) + status.to_hash.nil? +end +# => true +# => true +# => true +# => true +# => true +``` + +## Apply Template +```ruby +status = Sonarqube.apply_template({ projectName: 'New-Group', templateName: 'test' }) +status.to_hash.nil? +# => true +``` + +## Bulk apply template +```ruby +status = Sonarqube.bulk_apply_template({ templateName: 'test', projects: 'my_project,another_project' }) +# => #{"id"=>"AXQt1hhmsmLGhox2KqqJ", "name"=>"template_name", "description"=>"description", "projectKeyPattern"=>".*\\.finance\\..*", "createdAt"=>"2020-08-27T02:53:59+0000", "updatedAt"=>"2020-08-27T02:53:59+0000", "permissions"=>[]}}} +status.permissionTemplate.name +# => template_name +``` + +## Delete Template +```ruby +status = Sonarqube.delete_template({ templateName: 'template_name' }) +# => #{"id"=>"AXQt1hhmsmLGhox2KqqJ", "name"=>"template_name", "description"=>"description", "projectKeyPattern"=>".*\\.finance\\..*", "createdAt"=>"2020-08-27T02:53:59+0000", "updatedAt"=>"2020-08-27T02:53:59+0000", "permissions"=>[]}}} +status.to_hash.nil? +# => true +# => true +# => true +# => true +# => true +``` + +## Remove Permission from group +```ruby +['user', 'codeviewer', 'issueadmin', 'securityhotspotadmin', 'scan'].each do | permission | + status = Sonarqube.permissions_remove_group({groupName: 'New-Group', permission: permission, projectKey: 'test'}) + status.to_hash.nil? +end +# => true +# => true +# => true +# => true +# => true +``` diff --git a/lib/sonarqube/client.rb b/lib/sonarqube/client.rb index 3032d44..9a27857 100644 --- a/lib/sonarqube/client.rb +++ b/lib/sonarqube/client.rb @@ -7,6 +7,7 @@ module Sonarqube # Please keep in alphabetical order include Groups + include Permissions include Projects include Tokens include Users diff --git a/lib/sonarqube/client/permissions.rb b/lib/sonarqube/client/permissions.rb new file mode 100644 index 0000000..7c583b8 --- /dev/null +++ b/lib/sonarqube/client/permissions.rb @@ -0,0 +1,215 @@ +# frozen_string_literal: true + +class Sonarqube::Client + # Defines methods related to permissions. + # @see https://SONAR_URL/web_api/api/permissions + module Permissions + # Add permission to a group. + # + # @example + # Sonarqube.permissions_add_group({ groupName: 'New-Group', permission: 'user', projectKey: 'test' }) + # + # @param [Hash] options A customizable set of options. + # @option options [String] :groupId Id of group. + # @option options [String] :groupName Name of group. + # @option options [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user + # @option options [String] :projectId Id of project, only apply for project permissions. + # @option options [String] :projectKey Key of project, only apply for project permissions. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/add_group} + # @return [] + def permission_add_group(options = {}) + options.transform_keys(&:to_sym) + raise ArgumentError, 'Missing required parameters' if options[:groupId].nil? && options[:groupName].nil? + + post('/api/permissions/add_group', body: options) + end + alias add_group_permission permission_add_group + + # Add group to template. + # + # @example + # Sonarqube.add_group_to_template({ groupName: 'New-Group', permission: 'user', templateName: 'test' }) + # + # @param [Hash] options A customizable set of options. + # @option options [String] :groupId Id of group. + # @option options [String] :groupName Name of group. + # @option options [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user + # @option options [String] :templateId Id of template. + # @option options [String] :templateName Name of template. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/add_group_to_template} + # @return [] + def add_group_to_template(options = {}) + options.transform_keys(&:to_sym) + raise ArgumentError, 'Missing required parameters' if options[:groupId].nil? && options[:groupName].nil? + + post('/api/permissions/add_group_to_template', body: options) + end + + # Add project creator to template. + # + # @example + # Sonarqube.add_project_creator_to_template('issueadmin', { templateName: 'test' }) + # + # @param [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user + # @param [Hash] options A customizable set of options. + # @option options [String] :templateId Id of template. + # @option options [String] :templateName Name of template. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/add_project_creator_to_template} + # @return [] + def add_project_creator_to_template(permission, options = {}) + raise ArgumentError, 'Missing required parameters' if permission.nil? + + post('/api/permissions/add_project_creator_to_template', body: { permission: permission }.merge!(options)) + end + + # Add permissions to user. + # + # @example + # Sonarqube.permission_add_user('new_user', 'issueadmin', { projectKey: 'test' }) + # + # @param [String] :login Name of login user. + # @param [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user + # @param [Hash] options A customizable set of options. + # @option options [String] :projectId Id of project, only apply for project permissions. + # @option options [String] :projectKey Key of project, only apply for project permissions. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/add_user} + # @return [] + def permission_add_user(login, permission, options = {}) + options.transform_keys(&:to_sym) + raise ArgumentError, 'Missing required parameters' if login.nil? && permission.nil? + + body = { login: login, permission: permission }.merge!(options) + post('/api/permissions/add_user', body: body) + end + alias add_user_permission permission_add_user + + # Add user to template. + # + # @example + # Sonarqube.add_user_to_template({ 'new_user', 'issueadmin', { templateName: 'test' }) + # + # @param [String] :login Name of login user. + # @param [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user. + # @param [Hash] options A customizable set of options. + # @option options [String] :templateId Id of template. + # @option options [String] :templateName Name of template. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/add_user_to_template} + # @return [] + def add_user_to_template(login, permission, options = {}) + options.transform_keys(&:to_sym) + raise ArgumentError, 'Missing required parameters' if login.nil? && permission.nil? + + body = { login: login, permission: permission }.merge!(options) + post('/api/permissions/add_user_to_template', body: body) + end + + # Apply template. + # + # @example + # Sonarqube.apply_template({ projectName: 'New-Group', templateName: 'test' }) + # + # @param [Hash] options A customizable set of options. + # @option options [String] :projectId Id of group. + # @option options [String] :projectName Name of group. + # @option options [String] :templateId Id of template. + # @option options [String] :templateName Name of template. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/apply_template} + # @return [] + def apply_template(options = {}) + options.transform_keys(&:to_sym) + + post('/api/permissions/apply_template', body: options) + end + + # Bulk apply template. + # + # @example + # Sonarqube.bulk_apply_template({ templateName: 'test', projects: 'my_project,another_project' }) + # + # @param [Hash] options A customizable set of options. + # @option options [String] :analyzedBefore Filter the projects for which last analysis is older than the given date . + # @option options [String] :onProvisionedOnly Filter the projects that are provisioned. + # @option options [String] :projects Comma-separated list of project keys maximum 1000 + # @option options [String] :q serach project names that contain the supplied string and project keys that are exactly the same as the supplied string + # @option options [String] :qualifiers Comma-separated list of component qualifiers. Filter the results with the specified qualifiers. + # @option options [String] :templateId Id of template. + # @option options [String] :templateName Name of template. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/bulk_apply_template} + # @return [] + def bulk_apply_template(options = {}) + options.transform_keys(&:to_sym) + + post('/api/permissions/bulk_apply_template', body: options) + end + + # Create template. + # + # @example + # Sonarqube.create_template('template_name', 'description', '.*\.finance\..*') + # + # @param [String] :name Name of template. + # @param [String] :project_key_pattern Project key pattern. Must be a valid Java regular expression. + # @param [String] :description Description of template. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/create_template} + # @return [] + def create_template(name, description, project_key_pattern) + body = { name: name, description: description, projectKeyPattern: project_key_pattern } + post('/api/permissions/create_template', body: body) + end + + # Delete template. + # + # @example + # Sonarqube.create_template({ templateName: 'template_name' }) + # + # @param [Hash] options A customizable set of options. + # @option options [String] :templateId Id of template. + # @option options [String] :templateName Name of template. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/delete_template} + # @return [] + def delete_template(options = {}) + options.transform_keys(&:to_sym) + raise ArgumentError, 'Missing required parameters' if options[:templateName].nil? && options[:templateId].nil? + + post('/api/permissions/delete_template', body: options) + end + + # Remove permission to a group. + # + # @example + # Sonarqube.permissions_add_group({ groupName: 'New-Group', permission: permission, projectKey: 'test' }) + # + # @param [Hash] options A customizable set of options. + # @option options [String] :groupId Id of group. + # @option options [String] :groupName Name of group. + # @option options [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user + # @option options [String] :projectId Id of project, only apply for project permissions. + # @option options [String] :projectKey Key of project, only apply for project permissions. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/remove_group} + # @return [] + def permission_remove_group(options = {}) + options.transform_keys(&:to_sym) + raise ArgumentError, 'Missing required parameters' if options[:groupId].nil? && options[:groupName].nil? + + post('/api/permissions/remove_group', body: options) + end + alias remove_group_permission permission_remove_group + + # Remove group from template. + # + # @example + # Sonarqube.remove_group_from_template({ groupName: 'New-Group', permission: 'permission', templateId: 'test' }) + # + # @param [Hash] options A customizable set of options. + # @option options [String] :groupId Id of group. + # @option options [String] :groupName Name of group. + # @option options [String] :permission Permission to asing to group. global permissions: admin, profileadmin, gateadmin, scan, provisioning | project permissions: admin, codeviewer, issueadmin, securityhotspotadmin, scan, user + # @option options [String] :TemplateId Id of template. + # @option options [String] :TemplateName Name of template. + # (Any provided options will be passed to Sonarqube. See {https://SONAR_URL/web_api/api/permissions/remove_group_from_template} + # @return [] + def remove_group_from_template(options = {}) + post('/api/permissions/remove_group_from_template', body: options) + end + end +end diff --git a/spec/fixtures/apply_template.json b/spec/fixtures/apply_template.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/apply_template.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/fixtures/bulk_apply_template.json b/spec/fixtures/bulk_apply_template.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/bulk_apply_template.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/fixtures/create_template.json b/spec/fixtures/create_template.json new file mode 100644 index 0000000..15579fb --- /dev/null +++ b/spec/fixtures/create_template.json @@ -0,0 +1 @@ +{"permissionTemplate": {"name": "template_name","description": "description","projectKeyPattern": ".*\\.finance\\..*"}} \ No newline at end of file diff --git a/spec/fixtures/delete_template.json b/spec/fixtures/delete_template.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/delete_template.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/fixtures/permission_add_group.json b/spec/fixtures/permission_add_group.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/permission_add_group.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/fixtures/permission_add_user.json b/spec/fixtures/permission_add_user.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/permission_add_user.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/fixtures/permission_remove_group.json b/spec/fixtures/permission_remove_group.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/permission_remove_group.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/fixtures/remove_group_from_template.json b/spec/fixtures/remove_group_from_template.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/remove_group_from_template.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/fixtures/template_add_group.json b/spec/fixtures/template_add_group.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/template_add_group.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/fixtures/template_add_project_creator.json b/spec/fixtures/template_add_project_creator.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/template_add_project_creator.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/fixtures/template_add_user.json b/spec/fixtures/template_add_user.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/template_add_user.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/fixtures/template_remove_group.json b/spec/fixtures/template_remove_group.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/spec/fixtures/template_remove_group.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/spec/sonarqube/client/permissions_spec.rb b/spec/sonarqube/client/permissions_spec.rb new file mode 100644 index 0000000..3135426 --- /dev/null +++ b/spec/sonarqube/client/permissions_spec.rb @@ -0,0 +1,203 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Sonarqube::Client do + describe '.permission_add_group' do + context 'when successful request' do + before do + stub_post('/api/permissions/add_group', 'permission_add_group') + @permission = Sonarqube.permission_add_group({ groupName: 'New-Group', permission: 'user', projectKey: 'test' }) + end + + it 'gets the correct resource' do + body = { groupName: 'New-Group', permission: 'user', projectKey: 'test' } + expect(a_post('/api/permissions/add_group').with(body: body)).to have_been_made + end + + it 'returns empty hash' do + expect(@permission.to_hash).to be_empty + end + end + end + + describe '.add_group_to_template' do + context 'when successful request' do + before do + stub_post('/api/permissions/add_group_to_template', 'template_add_group') + @permission = Sonarqube.add_group_to_template({ groupName: 'New-Group', permission: 'user', templateName: 'test' }) + end + + it 'gets the correct resource' do + body = { groupName: 'New-Group', permission: 'user', templateName: 'test' } + expect(a_post('/api/permissions/add_group_to_template').with(body: body)).to have_been_made + end + + it 'returns returns empty hash' do + expect(@permission.to_hash).to be_empty + end + end + end + + describe '.add_project_creator_to_template' do + context 'when successful request' do + before do + stub_post('/api/permissions/add_project_creator_to_template', 'template_add_project_creator') + @permission = Sonarqube.add_project_creator_to_template('user', { templateName: 'test' }) + end + + it 'gets the correct resource' do + body = { permission: 'user', templateName: 'test' } + expect(a_post('/api/permissions/add_project_creator_to_template').with(body: body)).to have_been_made + end + + it 'returns returns empty hash' do + expect(@permission.to_hash).to be_empty + end + end + end + + describe '.permission_add_user' do + context 'when successful request' do + before do + stub_post('/api/permissions/add_user', 'permission_add_user') + @permission = Sonarqube.permission_add_user('user', 'user', { templateName: 'test' }) + end + + it 'gets the correct resource' do + body = { login: 'user', permission: 'user', templateName: 'test' } + expect(a_post('/api/permissions/add_user').with(body: body)).to have_been_made + end + + it 'returns returns empty hash' do + expect(@permission.to_hash).to be_empty + end + end + end + + describe '.add_user_to_template' do + context 'when successful request' do + before do + stub_post('/api/permissions/add_user_to_template', 'template_add_user') + @permission = Sonarqube.add_user_to_template('new_user', 'user', { templateName: 'test' }) + end + + it 'gets the correct resource' do + body = { login: 'new_user', permission: 'user', templateName: 'test' } + expect(a_post('/api/permissions/add_user_to_template').with(body: body)).to have_been_made + end + + it 'returns returns empty hash' do + expect(@permission.to_hash).to be_empty + end + end + end + + describe '.apply_template' do + context 'when successful request' do + before do + stub_post('/api/permissions/apply_template', 'apply_template') + @permission = Sonarqube.apply_template({ projectName: 'test', templateName: 'test' }) + end + + it 'gets the correct resource' do + body = { projectName: 'test', templateName: 'test' } + expect(a_post('/api/permissions/apply_template').with(body: body)).to have_been_made + end + + it 'returns returns empty hash' do + expect(@permission.to_hash).to be_empty + end + end + end + + describe '.bulk_apply_template' do + context 'when successful request' do + before do + stub_post('/api/permissions/bulk_apply_template', 'bulk_apply_template') + @permission = Sonarqube.bulk_apply_template({ projectName: 'test', templateName: 'test' }) + end + + it 'gets the correct resource' do + body = { projectName: 'test', templateName: 'test' } + expect(a_post('/api/permissions/bulk_apply_template').with(body: body)).to have_been_made + end + + it 'returns returns empty hash' do + expect(@permission.to_hash).to be_empty + end + end + end + + describe '.create_template' do + context 'when successful request' do + before do + stub_post('/api/permissions/create_template', 'create_template') + @permission = Sonarqube.create_template('template_name', 'description', '.*\.finance\..*') + end + + it 'gets the correct resource' do + body = { name: 'template_name', description: 'description', projectKeyPattern: '.*\.finance\..*' } + expect(a_post('/api/permissions/create_template').with(body: body)).to have_been_made + end + + it 'returns returns empty hash' do + expect(@permission.permissionTemplate.name).to eq('template_name') + end + end + end + + describe '.delete_template' do + context 'when successful request' do + before do + stub_post('/api/permissions/delete_template', 'delete_template') + @permission = Sonarqube.delete_template({ templateName: 'template_name' }) + end + + it 'gets the correct resource' do + body = { templateName: 'template_name' } + expect(a_post('/api/permissions/delete_template').with(body: body)).to have_been_made + end + + it 'returns returns empty hash' do + expect(@permission.to_hash).to be_empty + end + end + end + + describe '.permission_remove_group' do + context 'when successful request' do + before do + stub_post('/api/permissions/remove_group', 'permission_remove_group') + @permission = Sonarqube.permission_remove_group({ groupName: 'New-Group', permission: 'user', projectKey: 'test' }) + end + + it 'gets the correct resource' do + body = { groupName: 'New-Group', permission: 'user', projectKey: 'test' } + expect(a_post('/api/permissions/remove_group').with(body: body)).to have_been_made + end + + it 'returns returns empty hash' do + expect(@permission.to_hash).to be_empty + end + end + end + + describe '.remove_group_from_template' do + context 'when successful request' do + before do + stub_post('/api/permissions/remove_group_from_template', 'remove_group_from_template') + @permission = Sonarqube.remove_group_from_template({ groupName: 'New-Group', permission: 'permission', templateName: 'test' }) + end + + it 'gets the correct resource' do + body = { groupName: 'New-Group', permission: 'permission', templateName: 'test' } + expect(a_post('/api/permissions/remove_group_from_template').with(body: body)).to have_been_made + end + + it 'returns returns empty hash' do + expect(@permission.to_hash).to be_empty + end + end + end +end diff --git a/spec/sonarqube_spec.rb b/spec/sonarqube_spec.rb index 6ec6be4..510a4ed 100644 --- a/spec/sonarqube_spec.rb +++ b/spec/sonarqube_spec.rb @@ -30,7 +30,7 @@ describe Sonarqube do actions = described_class.actions expect(actions).to be_an Array expect(actions.first).to be_a Symbol - expect(actions.min).to eq(:add_member) + expect(actions.min).to eq(:add_group_permission) end end