jenkins_api_client 1.4.5 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/jenkins_api_client.gemspec +15 -136
- data/lib/jenkins_api_client/version.rb +2 -2
- metadata +6 -180
- data/.gitignore +0 -41
- data/.jenkins.yml +0 -9
- data/.travis.yml +0 -15
- data/CHANGELOG.md +0 -391
- data/CONTRIBUTORS.md +0 -3
- data/Gemfile +0 -20
- data/LICENCE +0 -21
- data/README.md +0 -454
- data/Rakefile +0 -107
- data/Vagrantfile +0 -83
- data/config/login.yml.example +0 -27
- data/jenkins_api_client_class_diagram.png +0 -0
- data/scripts/login_with_irb.rb +0 -54
- data/scripts/login_with_pry.rb +0 -54
- data/spec/func_tests/client_spec.rb +0 -109
- data/spec/func_tests/job_spec.rb +0 -669
- data/spec/func_tests/node_spec.rb.pending +0 -217
- data/spec/func_tests/plugin_spec.rb +0 -148
- data/spec/func_tests/spec_helper.rb +0 -41
- data/spec/func_tests/system_spec.rb +0 -84
- data/spec/func_tests/user_spec.rb +0 -49
- data/spec/func_tests/view_spec.rb +0 -276
- data/spec/unit_tests/build_queue_spec.rb +0 -152
- data/spec/unit_tests/client_spec.rb +0 -471
- data/spec/unit_tests/fake_http_response.rb +0 -9
- data/spec/unit_tests/fixtures/files/available_plugins.json +0 -1
- data/spec/unit_tests/fixtures/files/computer_sample.xml +0 -17
- data/spec/unit_tests/fixtures/files/installed_plugins.json +0 -1
- data/spec/unit_tests/fixtures/files/job_sample.xml +0 -16
- data/spec/unit_tests/fixtures/files/updatable_plugins.json +0 -1
- data/spec/unit_tests/job_spec.rb +0 -783
- data/spec/unit_tests/node_spec.rb +0 -342
- data/spec/unit_tests/plugin_settings/colllection_spec.rb +0 -62
- data/spec/unit_tests/plugin_settings/hipchat_spec.rb +0 -44
- data/spec/unit_tests/plugin_settings/workspace_cleanup_spec.rb +0 -31
- data/spec/unit_tests/plugin_spec.rb +0 -165
- data/spec/unit_tests/spec_helper.rb +0 -19
- data/spec/unit_tests/system_spec.rb +0 -76
- data/spec/unit_tests/user_spec.rb +0 -144
- data/spec/unit_tests/view_spec.rb +0 -149
- data/travis/hudson.model.UpdateCenter.xml +0 -7
- data/travis/jenkins_config.xml +0 -63
- data/travis/jenkins_config_with_crumb.xml +0 -67
- data/travis/setup.sh +0 -23
- data/travis/setup_crumb.sh +0 -11
- data/travis/spec.yml +0 -14
- data/travis/user_config.xml +0 -29
| @@ -1,217 +0,0 @@ | |
| 1 | 
            -
            #
         | 
| 2 | 
            -
            # Specifying JenkinsApi::Client::Node class capabilities
         | 
| 3 | 
            -
            # Author Kannan Manickam <arangamani.kannan@gmail.com>
         | 
| 4 | 
            -
            #
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            require File.expand_path('../spec_helper', __FILE__)
         | 
| 7 | 
            -
            require 'yaml'
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            describe JenkinsApi::Client::Node do
         | 
| 10 | 
            -
              context "With properly initialized client" do
         | 
| 11 | 
            -
                before(:all) do
         | 
| 12 | 
            -
                  @creds_file = '~/.jenkins_api_client/spec.yml'
         | 
| 13 | 
            -
                  @valid_post_responses = [200, 201, 302]
         | 
| 14 | 
            -
                  @node_name = 'master'
         | 
| 15 | 
            -
                  begin
         | 
| 16 | 
            -
                    @client = JenkinsApi::Client.new(
         | 
| 17 | 
            -
                      YAML.load_file(File.expand_path(@creds_file, __FILE__))
         | 
| 18 | 
            -
                    )
         | 
| 19 | 
            -
                  rescue Exception => e
         | 
| 20 | 
            -
                    puts "WARNING: Credentials are not set properly."
         | 
| 21 | 
            -
                    puts e.message
         | 
| 22 | 
            -
                  end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                  @client.node.create_dumb_slave(
         | 
| 25 | 
            -
                    :name => "slave",
         | 
| 26 | 
            -
                    :slave_host => "10.0.0.1",
         | 
| 27 | 
            -
                    :private_key_file => "/root/.ssh/id_rsa"
         | 
| 28 | 
            -
                  ) unless @client.node.list.include?("slave")
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                describe "InstanceMethods" do
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                  describe "#initialize" do
         | 
| 34 | 
            -
                    it "Initializes without any exception" do
         | 
| 35 | 
            -
                      expect(
         | 
| 36 | 
            -
                        lambda{ node = JenkinsApi::Client::Node.new(@client) }
         | 
| 37 | 
            -
                      ).not_to raise_error
         | 
| 38 | 
            -
                    end
         | 
| 39 | 
            -
                    it "Raises an error if a reference of client is not passed" do
         | 
| 40 | 
            -
                      expect(
         | 
| 41 | 
            -
                        lambda{ node JenkinsApi::Client::Node.new() }
         | 
| 42 | 
            -
                      ).to raise_error
         | 
| 43 | 
            -
                    end
         | 
| 44 | 
            -
                  end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                  describe "#create_dumb_slave" do
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                    def test_and_validate(params)
         | 
| 49 | 
            -
                      name = params[:name]
         | 
| 50 | 
            -
                      @valid_post_responses.should include(
         | 
| 51 | 
            -
                        @client.node.create_dumb_slave(params).to_i
         | 
| 52 | 
            -
                      )
         | 
| 53 | 
            -
                      @client.node.list(name).include?(name).should be_true
         | 
| 54 | 
            -
                      @valid_post_responses.should include(
         | 
| 55 | 
            -
                        @client.node.delete(params[:name]).to_i
         | 
| 56 | 
            -
                      )
         | 
| 57 | 
            -
                      @client.node.list(name).include?(name).should be_false
         | 
| 58 | 
            -
                    end
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                    it "accepts required params and creates the slave on jenkins" do
         | 
| 61 | 
            -
                      params = {
         | 
| 62 | 
            -
                        :name => "func_test_slave",
         | 
| 63 | 
            -
                        :slave_host => "10.10.10.10",
         | 
| 64 | 
            -
                        :private_key_file => "/root/.ssh/id_rsa"
         | 
| 65 | 
            -
                      }
         | 
| 66 | 
            -
                      test_and_validate(params)
         | 
| 67 | 
            -
                    end
         | 
| 68 | 
            -
                    it "accepts spaces and other characters in node name" do
         | 
| 69 | 
            -
                      params = {
         | 
| 70 | 
            -
                        :name => "slave with spaces and {special characters}",
         | 
| 71 | 
            -
                        :slave_host => "10.10.10.10",
         | 
| 72 | 
            -
                        :private_key_file => "/root/.ssh/id_rsa"
         | 
| 73 | 
            -
                      }
         | 
| 74 | 
            -
                      test_and_validate(params)
         | 
| 75 | 
            -
                    end
         | 
| 76 | 
            -
                    it "fails if name is missing" do
         | 
| 77 | 
            -
                      params = {
         | 
| 78 | 
            -
                        :slave_host => "10.10.10.10",
         | 
| 79 | 
            -
                        :private_key_file => "/root/.ssh/id_rsa"
         | 
| 80 | 
            -
                      }
         | 
| 81 | 
            -
                      expect(
         | 
| 82 | 
            -
                        lambda{ @client.node.create_dumb_slave(params) }
         | 
| 83 | 
            -
                      ).to raise_error(ArgumentError)
         | 
| 84 | 
            -
                    end
         | 
| 85 | 
            -
                    it "fails if slave_host is missing" do
         | 
| 86 | 
            -
                      params = {
         | 
| 87 | 
            -
                        :name => "func_test_slave",
         | 
| 88 | 
            -
                        :private_key_file => "/root/.ssh/id_rsa"
         | 
| 89 | 
            -
                      }
         | 
| 90 | 
            -
                      expect(
         | 
| 91 | 
            -
                        lambda{ @client.node.create_dumb_slave(params) }
         | 
| 92 | 
            -
                      ).to raise_error(ArgumentError)
         | 
| 93 | 
            -
                    end
         | 
| 94 | 
            -
                    it "fails if private_key_file is missing" do
         | 
| 95 | 
            -
                      params = {
         | 
| 96 | 
            -
                        :name => "func_test_slave",
         | 
| 97 | 
            -
                        :slave_host => "10.10.10.10"
         | 
| 98 | 
            -
                      }
         | 
| 99 | 
            -
                      expect(
         | 
| 100 | 
            -
                        lambda{ @client.node.create_dumb_slave(params) }
         | 
| 101 | 
            -
                      ).to raise_error(ArgumentError)
         | 
| 102 | 
            -
                    end
         | 
| 103 | 
            -
                    it "fails if the slave already exists in Jenkins" do
         | 
| 104 | 
            -
                      params = {
         | 
| 105 | 
            -
                        :name => "func_test_slave",
         | 
| 106 | 
            -
                        :slave_host => "10.10.10.10",
         | 
| 107 | 
            -
                        :private_key_file => "/root/.ssh/id_rsa"
         | 
| 108 | 
            -
                      }
         | 
| 109 | 
            -
                      @valid_post_responses.should include(
         | 
| 110 | 
            -
                        @client.node.create_dumb_slave(params).to_i
         | 
| 111 | 
            -
                      )
         | 
| 112 | 
            -
                      expect(
         | 
| 113 | 
            -
                        lambda{ @client.node.create_dumb_slave(params) }
         | 
| 114 | 
            -
                      ).to raise_error(JenkinsApi::Exceptions::NodeAlreadyExists)
         | 
| 115 | 
            -
                      @valid_post_responses.should include(
         | 
| 116 | 
            -
                        @client.node.delete(params[:name]).to_i
         | 
| 117 | 
            -
                      )
         | 
| 118 | 
            -
                    end
         | 
| 119 | 
            -
                  end
         | 
| 120 | 
            -
             | 
| 121 | 
            -
                  describe "#delete" do
         | 
| 122 | 
            -
                    it "deletes the node given the name" do
         | 
| 123 | 
            -
                      params = {
         | 
| 124 | 
            -
                        :name => "func_test_slave",
         | 
| 125 | 
            -
                        :slave_host => "10.10.10.10",
         | 
| 126 | 
            -
                        :private_key_file => "/root/.ssh/id_rsa"
         | 
| 127 | 
            -
                      }
         | 
| 128 | 
            -
                      @valid_post_responses.should include(
         | 
| 129 | 
            -
                        @client.node.create_dumb_slave(params).to_i
         | 
| 130 | 
            -
                      )
         | 
| 131 | 
            -
                      @valid_post_responses.should include(
         | 
| 132 | 
            -
                        @client.node.delete(params[:name]).to_i
         | 
| 133 | 
            -
                      )
         | 
| 134 | 
            -
                    end
         | 
| 135 | 
            -
                    it "raises an error if the slave doesn't exist in Jenkins" do
         | 
| 136 | 
            -
                      expect(
         | 
| 137 | 
            -
                        lambda{ @client.node.delete("not_there") }
         | 
| 138 | 
            -
                      ).to raise_error
         | 
| 139 | 
            -
                    end
         | 
| 140 | 
            -
                  end
         | 
| 141 | 
            -
             | 
| 142 | 
            -
                  describe "#list" do
         | 
| 143 | 
            -
                    it "Should be able to list all nodes" do
         | 
| 144 | 
            -
                      @client.node.list.class.should == Array
         | 
| 145 | 
            -
                    end
         | 
| 146 | 
            -
                  end
         | 
| 147 | 
            -
             | 
| 148 | 
            -
                  describe "GeneralAttributes" do
         | 
| 149 | 
            -
                    general_attributes = JenkinsApi::Client::Node::GENERAL_ATTRIBUTES
         | 
| 150 | 
            -
                    general_attributes.each do |attribute|
         | 
| 151 | 
            -
                      describe "#get_#{attribute}" do
         | 
| 152 | 
            -
                        it "should get the #{attribute} attribute" do
         | 
| 153 | 
            -
                          @client.node.method("get_#{attribute}").call
         | 
| 154 | 
            -
                        end
         | 
| 155 | 
            -
                      end
         | 
| 156 | 
            -
                    end
         | 
| 157 | 
            -
                  end
         | 
| 158 | 
            -
             | 
| 159 | 
            -
                  describe "NodeProperties" do
         | 
| 160 | 
            -
                    node_properties = JenkinsApi::Client::Node::NODE_PROPERTIES
         | 
| 161 | 
            -
                    node_properties.each do |property|
         | 
| 162 | 
            -
                      describe "#is_#{property}" do
         | 
| 163 | 
            -
                        it "should get the #{property} property" do
         | 
| 164 | 
            -
                          @client.node.method("is_#{property}?").call(@node_name)
         | 
| 165 | 
            -
                        end
         | 
| 166 | 
            -
                      end
         | 
| 167 | 
            -
                    end
         | 
| 168 | 
            -
                  end
         | 
| 169 | 
            -
             | 
| 170 | 
            -
                  describe "NodeAttributes" do
         | 
| 171 | 
            -
                    node_attributes = JenkinsApi::Client::Node::NODE_ATTRIBUTES
         | 
| 172 | 
            -
                    node_attributes.each do |attribute|
         | 
| 173 | 
            -
                      describe "#get_node_#{attribute}" do
         | 
| 174 | 
            -
                        it "Should be able to list all node attributes" do
         | 
| 175 | 
            -
                          @client.node.method("get_node_#{attribute}").call(@node_name)
         | 
| 176 | 
            -
                        end
         | 
| 177 | 
            -
                      end
         | 
| 178 | 
            -
                    end
         | 
| 179 | 
            -
                  end
         | 
| 180 | 
            -
             | 
| 181 | 
            -
                  describe "#change_mode" do
         | 
| 182 | 
            -
                    it "changes the mode of the given slave to the given mode" do
         | 
| 183 | 
            -
                      @valid_post_responses.should include(
         | 
| 184 | 
            -
                        @client.node.change_mode("slave", "exclusive").to_i
         | 
| 185 | 
            -
                      )
         | 
| 186 | 
            -
                      @valid_post_responses.should include(
         | 
| 187 | 
            -
                        @client.node.change_mode("slave", "normal").to_i
         | 
| 188 | 
            -
                      )
         | 
| 189 | 
            -
                    end
         | 
| 190 | 
            -
                  end
         | 
| 191 | 
            -
             | 
| 192 | 
            -
                  describe "#get_config" do
         | 
| 193 | 
            -
                    it "obtaines the node config.xml from the server" do
         | 
| 194 | 
            -
                      expect(
         | 
| 195 | 
            -
                        lambda { @client.node.get_config("slave") }
         | 
| 196 | 
            -
                      ).not_to raise_error
         | 
| 197 | 
            -
                    end
         | 
| 198 | 
            -
                  end
         | 
| 199 | 
            -
             | 
| 200 | 
            -
                  describe "#post_config" do
         | 
| 201 | 
            -
                    it "posts the given config.xml to the jenkins server's node" do
         | 
| 202 | 
            -
                      expect(
         | 
| 203 | 
            -
                        lambda {
         | 
| 204 | 
            -
                          xml = @client.node.get_config("slave")
         | 
| 205 | 
            -
                          @client.node.post_config("slave", xml)
         | 
| 206 | 
            -
                        }
         | 
| 207 | 
            -
                      ).not_to raise_error
         | 
| 208 | 
            -
                    end
         | 
| 209 | 
            -
                  end
         | 
| 210 | 
            -
             | 
| 211 | 
            -
                end
         | 
| 212 | 
            -
             | 
| 213 | 
            -
                after(:all) do
         | 
| 214 | 
            -
                  @client.node.delete("slave")
         | 
| 215 | 
            -
                end
         | 
| 216 | 
            -
              end
         | 
| 217 | 
            -
            end
         | 
| @@ -1,148 +0,0 @@ | |
| 1 | 
            -
            #
         | 
| 2 | 
            -
            # Specifying JenkinsApi::Client::PluginManager class capabilities
         | 
| 3 | 
            -
            # Author Kannan Manickam <arangamani.kannan@gmail.com>
         | 
| 4 | 
            -
            #
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            require File.expand_path('../spec_helper', __FILE__)
         | 
| 7 | 
            -
            require 'yaml'
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            describe JenkinsApi::Client::PluginManager do
         | 
| 10 | 
            -
              context "With properly initialized client" do
         | 
| 11 | 
            -
                before(:all) do
         | 
| 12 | 
            -
                  @creds_file = '~/.jenkins_api_client/spec.yml'
         | 
| 13 | 
            -
                  @valid_post_responses = [200, 201, 302]
         | 
| 14 | 
            -
                  @test_plugin = "scripttrigger"
         | 
| 15 | 
            -
                  @test_plugins = ["text-finder", "terminal", "warnings"]
         | 
| 16 | 
            -
                  begin
         | 
| 17 | 
            -
                    @client = JenkinsApi::Client.new(
         | 
| 18 | 
            -
                      YAML.load_file(File.expand_path(@creds_file, __FILE__))
         | 
| 19 | 
            -
                    )
         | 
| 20 | 
            -
                    @client.init_update_center
         | 
| 21 | 
            -
                    sleep 30
         | 
| 22 | 
            -
                  rescue Exception => e
         | 
| 23 | 
            -
                    puts "WARNING: Credentials are not set properly."
         | 
| 24 | 
            -
                    puts e.message
         | 
| 25 | 
            -
                  end
         | 
| 26 | 
            -
                end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                describe "InstanceMethods" do
         | 
| 29 | 
            -
                  describe "#list_installed" do
         | 
| 30 | 
            -
                    it "lists all installed plugins in jenkins" do
         | 
| 31 | 
            -
                      @client.plugin.list_installed.class.should == Hash
         | 
| 32 | 
            -
                    end
         | 
| 33 | 
            -
                    supported_filters = [
         | 
| 34 | 
            -
                      :active, :bundled, :deleted, :downgradable, :enabled,
         | 
| 35 | 
            -
                      :hasUpdate, :pinned
         | 
| 36 | 
            -
                    ]
         | 
| 37 | 
            -
                    supported_filters.each do |filter|
         | 
| 38 | 
            -
                      it "lists all installed plugins matching filter '#{filter}'" do
         | 
| 39 | 
            -
                        @client.plugin.list_installed(filter => true).class.should == Hash
         | 
| 40 | 
            -
                      end
         | 
| 41 | 
            -
                    end
         | 
| 42 | 
            -
                    it "raises an error if unsupported filter is specified" do
         | 
| 43 | 
            -
                      expect(
         | 
| 44 | 
            -
                        lambda { @client.plugin.list_installed(:unsupported => true) }
         | 
| 45 | 
            -
                      ).to raise_error(ArgumentError)
         | 
| 46 | 
            -
                    end
         | 
| 47 | 
            -
                  end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                  describe "#list_available" do
         | 
| 50 | 
            -
                    it "lists all available plugins in jenkins update center" do
         | 
| 51 | 
            -
                      @client.plugin.list_available.class.should == Hash
         | 
| 52 | 
            -
                    end
         | 
| 53 | 
            -
                  end
         | 
| 54 | 
            -
             | 
| 55 | 
            -
                  describe "#list_updates" do
         | 
| 56 | 
            -
                    it "lists all available plugin updates in jenkins update center" do
         | 
| 57 | 
            -
                      @client.plugin.list_updates.class.should == Hash
         | 
| 58 | 
            -
                    end
         | 
| 59 | 
            -
                  end
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                  describe "#install, #restart_required?" do
         | 
| 62 | 
            -
                    it "installs a single plugin given as a string" do
         | 
| 63 | 
            -
                      @client.plugin.install(@test_plugin)
         | 
| 64 | 
            -
                      # Plugin installation might take a bit
         | 
| 65 | 
            -
                      sleep 5
         | 
| 66 | 
            -
                      @client.system.restart(true) if @client.plugin.restart_required?
         | 
| 67 | 
            -
                      @client.system.wait_for_ready
         | 
| 68 | 
            -
                      @client.plugin.list_installed.keys.should include(@test_plugin)
         | 
| 69 | 
            -
                    end
         | 
| 70 | 
            -
                    it "installs multiple plugins given as an array" do
         | 
| 71 | 
            -
                      @client.plugin.install(@test_plugins)
         | 
| 72 | 
            -
                      # Plugin installation might take a bit
         | 
| 73 | 
            -
                      sleep 15
         | 
| 74 | 
            -
                      @client.system.restart(true) if @client.plugin.restart_required?
         | 
| 75 | 
            -
                      @client.system.wait_for_ready
         | 
| 76 | 
            -
                      installed = @client.plugin.list_installed.keys
         | 
| 77 | 
            -
                      @test_plugins.all? { |plugin| installed.include?(plugin) }.
         | 
| 78 | 
            -
                        should == true
         | 
| 79 | 
            -
                    end
         | 
| 80 | 
            -
                  end
         | 
| 81 | 
            -
             | 
| 82 | 
            -
                  describe "#disable, #restart_required?" do
         | 
| 83 | 
            -
                    it "disables a single plugin given as a string" do
         | 
| 84 | 
            -
                      @client.plugin.disable(@test_plugin)
         | 
| 85 | 
            -
                      # Plugin installation might take a bit
         | 
| 86 | 
            -
                      sleep 5
         | 
| 87 | 
            -
                      @client.system.restart(true)
         | 
| 88 | 
            -
                      @client.system.wait_for_ready
         | 
| 89 | 
            -
                      @client.plugin.list_installed(:active => false).keys.
         | 
| 90 | 
            -
                        should include(@test_plugin)
         | 
| 91 | 
            -
                    end
         | 
| 92 | 
            -
                    it "disables multiple plugins given as an array" do
         | 
| 93 | 
            -
                      @client.plugin.disable(@test_plugins)
         | 
| 94 | 
            -
                      # Plugin installation might take a bit
         | 
| 95 | 
            -
                      sleep 5
         | 
| 96 | 
            -
                      @client.system.restart(true)
         | 
| 97 | 
            -
                      @client.system.wait_for_ready
         | 
| 98 | 
            -
                      installed = @client.plugin.list_installed(:active => false).keys
         | 
| 99 | 
            -
                      @test_plugins.all? { |plugin| installed.include?(plugin) }.
         | 
| 100 | 
            -
                        should == true
         | 
| 101 | 
            -
                    end
         | 
| 102 | 
            -
                  end
         | 
| 103 | 
            -
             | 
| 104 | 
            -
                  describe "#enable, #restart_required?" do
         | 
| 105 | 
            -
                    it "enables a single plugin given as a string" do
         | 
| 106 | 
            -
                      @client.plugin.enable(@test_plugin)
         | 
| 107 | 
            -
                      # Plugin installation might take a bit
         | 
| 108 | 
            -
                      sleep 5
         | 
| 109 | 
            -
                      @client.system.restart(true)
         | 
| 110 | 
            -
                      @client.system.wait_for_ready
         | 
| 111 | 
            -
                      @client.plugin.list_installed(:active => true).keys.
         | 
| 112 | 
            -
                        should include(@test_plugin)
         | 
| 113 | 
            -
                    end
         | 
| 114 | 
            -
                    it "enables multiple plugins given as an array" do
         | 
| 115 | 
            -
                      @client.plugin.enable(@test_plugins)
         | 
| 116 | 
            -
                      # Plugin installation might take a bit
         | 
| 117 | 
            -
                      sleep 5
         | 
| 118 | 
            -
                      @client.system.restart(true)
         | 
| 119 | 
            -
                      @client.system.wait_for_ready
         | 
| 120 | 
            -
                      installed = @client.plugin.list_installed(:active => true).keys
         | 
| 121 | 
            -
                      @test_plugins.all? { |plugin| installed.include?(plugin) }.
         | 
| 122 | 
            -
                        should == true
         | 
| 123 | 
            -
                    end
         | 
| 124 | 
            -
                  end
         | 
| 125 | 
            -
             | 
| 126 | 
            -
                  describe "#uninstall, #restart_required?" do
         | 
| 127 | 
            -
                    it "uninstalls a single plugin given as a string" do
         | 
| 128 | 
            -
                      @client.plugin.uninstall(@test_plugin)
         | 
| 129 | 
            -
                      # Plugin uninstallation might take a bit
         | 
| 130 | 
            -
                      sleep 5
         | 
| 131 | 
            -
                      @client.system.restart(true) if @client.plugin.restart_required?
         | 
| 132 | 
            -
                      @client.system.wait_for_ready
         | 
| 133 | 
            -
                      @client.plugin.list_installed.keys.should_not include(@test_plugin)
         | 
| 134 | 
            -
                    end
         | 
| 135 | 
            -
                    it "uninstalls multiple plugins given as an array" do
         | 
| 136 | 
            -
                      @client.plugin.uninstall(@test_plugins)
         | 
| 137 | 
            -
                      # Plugin uninstallation might take a bit
         | 
| 138 | 
            -
                      sleep 5
         | 
| 139 | 
            -
                      @client.system.restart(true) if @client.plugin.restart_required?
         | 
| 140 | 
            -
                      @client.system.wait_for_ready
         | 
| 141 | 
            -
                      installed = @client.plugin.list_installed.keys
         | 
| 142 | 
            -
                      @test_plugins.all? { |plugin| installed.include?(plugin) }.
         | 
| 143 | 
            -
                        should == false
         | 
| 144 | 
            -
                    end
         | 
| 145 | 
            -
                  end
         | 
| 146 | 
            -
                end
         | 
| 147 | 
            -
              end
         | 
| 148 | 
            -
            end
         | 
| @@ -1,41 +0,0 @@ | |
| 1 | 
            -
            #
         | 
| 2 | 
            -
            # Helper functions for Ruby specifications
         | 
| 3 | 
            -
            # Author: Kannan Manickam <arangamani.kannan@gmail.com>
         | 
| 4 | 
            -
            #
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            require 'simplecov'
         | 
| 7 | 
            -
            SimpleCov.start if ENV["COVERAGE"]
         | 
| 8 | 
            -
            require File.expand_path('../../../lib/jenkins_api_client', __FILE__)
         | 
| 9 | 
            -
            require 'pp'
         | 
| 10 | 
            -
            require 'yaml'
         | 
| 11 | 
            -
            require 'nokogiri'
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            module JenkinsApiSpecHelper
         | 
| 14 | 
            -
              class Helper
         | 
| 15 | 
            -
                def create_job_xml
         | 
| 16 | 
            -
                  builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') { |xml|
         | 
| 17 | 
            -
                    xml.project {
         | 
| 18 | 
            -
                      xml.actions
         | 
| 19 | 
            -
                      xml.description
         | 
| 20 | 
            -
                      xml.keepDependencies "false"
         | 
| 21 | 
            -
                      xml.properties
         | 
| 22 | 
            -
                      xml.scm(:class => "hudson.scm.NullSCM")
         | 
| 23 | 
            -
                      xml.canRoam "true"
         | 
| 24 | 
            -
                      xml.disabled "false"
         | 
| 25 | 
            -
                      xml.blockBuildWhenDownstreamBuilding "false"
         | 
| 26 | 
            -
                      xml.blockBuildWhenUpstreamBuilding "false"
         | 
| 27 | 
            -
                      xml.triggers.vector
         | 
| 28 | 
            -
                      xml.concurrentBuild "false"
         | 
| 29 | 
            -
                      xml.builders {
         | 
| 30 | 
            -
                        xml.send("hudson.tasks.Shell") {
         | 
| 31 | 
            -
                          xml.command "\necho 'going to take a nice nap'\nsleep 15\necho 'took a nice nap'"
         | 
| 32 | 
            -
                        }
         | 
| 33 | 
            -
                      }
         | 
| 34 | 
            -
                      xml.publishers
         | 
| 35 | 
            -
                      xml.buildWrappers
         | 
| 36 | 
            -
                    }
         | 
| 37 | 
            -
                  }
         | 
| 38 | 
            -
                  builder.to_xml
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
              end
         | 
| 41 | 
            -
            end
         | 
| @@ -1,84 +0,0 @@ | |
| 1 | 
            -
            #
         | 
| 2 | 
            -
            # Specifying JenkinsApi::Client::System class capabilities
         | 
| 3 | 
            -
            # Author: Kannan Manickam <arangamani.kannan@gmail.com>
         | 
| 4 | 
            -
            #
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            require File.expand_path('../spec_helper', __FILE__)
         | 
| 7 | 
            -
            require 'yaml'
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            describe JenkinsApi::Client::System do
         | 
| 10 | 
            -
              context "With properly initialized client" do
         | 
| 11 | 
            -
                before(:all) do
         | 
| 12 | 
            -
                  @creds_file = '~/.jenkins_api_client/spec.yml'
         | 
| 13 | 
            -
                  @valid_post_responses = [200, 201, 302]
         | 
| 14 | 
            -
                  begin
         | 
| 15 | 
            -
                    @client = JenkinsApi::Client.new(
         | 
| 16 | 
            -
                      YAML.load_file(File.expand_path(@creds_file, __FILE__))
         | 
| 17 | 
            -
                    )
         | 
| 18 | 
            -
                  rescue Exception => e
         | 
| 19 | 
            -
                    puts "WARNING: Credentials are not set properly."
         | 
| 20 | 
            -
                    puts e.message
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                describe "InstanceMethods" do
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                  describe "#quiet_down" do
         | 
| 27 | 
            -
                    it "Should be able to quiet down a Jenkins server" do
         | 
| 28 | 
            -
                      @valid_post_responses.should include(
         | 
| 29 | 
            -
                        @client.system.quiet_down.to_i
         | 
| 30 | 
            -
                      )
         | 
| 31 | 
            -
                    end
         | 
| 32 | 
            -
                  end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                  describe "#cancel_quiet_down" do
         | 
| 35 | 
            -
                    it "Should be able to cancel the quiet down a Jenkins server" do
         | 
| 36 | 
            -
                      @valid_post_responses.should include(
         | 
| 37 | 
            -
                        @client.system.cancel_quiet_down.to_i
         | 
| 38 | 
            -
                      )
         | 
| 39 | 
            -
                    end
         | 
| 40 | 
            -
                  end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                  describe "#restart" do
         | 
| 43 | 
            -
                    it "Should be able to restart a Jenkins server safely" do
         | 
| 44 | 
            -
                      @valid_post_responses.should include(
         | 
| 45 | 
            -
                        @client.system.restart.to_i
         | 
| 46 | 
            -
                      )
         | 
| 47 | 
            -
                    end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                    it "Should be able to wait after a safe restart" do
         | 
| 50 | 
            -
                      @client.system.wait_for_ready.should == true
         | 
| 51 | 
            -
                    end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                    it "Should be able to force restart a Jenkins server" do
         | 
| 54 | 
            -
                      @valid_post_responses.should include(
         | 
| 55 | 
            -
                        @client.system.restart(true).to_i
         | 
| 56 | 
            -
                      )
         | 
| 57 | 
            -
                    end
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                    it "Should be able to wait after a force restart" do
         | 
| 60 | 
            -
                      @client.system.wait_for_ready.should == true
         | 
| 61 | 
            -
                    end
         | 
| 62 | 
            -
                  end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                  describe "#reload" do
         | 
| 65 | 
            -
                    it "Should be able to reload a Jenkins server" do
         | 
| 66 | 
            -
                      @valid_post_responses.should include(
         | 
| 67 | 
            -
                        @client.system.reload.to_i
         | 
| 68 | 
            -
                      )
         | 
| 69 | 
            -
                    end
         | 
| 70 | 
            -
                    it "Should be able to wait after a force restart" do
         | 
| 71 | 
            -
                      @client.system.wait_for_ready.should == true
         | 
| 72 | 
            -
                    end
         | 
| 73 | 
            -
                  end
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                  describe "#list_users" do
         | 
| 76 | 
            -
                    it "Should be able to get a list of users" do
         | 
| 77 | 
            -
                      @client.system.list_users.should be_an_instance_of(Array)
         | 
| 78 | 
            -
                    end
         | 
| 79 | 
            -
                  end
         | 
| 80 | 
            -
             | 
| 81 | 
            -
                end
         | 
| 82 | 
            -
             | 
| 83 | 
            -
              end
         | 
| 84 | 
            -
            end
         |