serverspec-vyos-config 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1ee2f56402453095fadf02f3b6f24a58416cde07
4
+ data.tar.gz: 0a5096a7cf051fc274a1861aa8749f6487b56e9e
5
+ SHA512:
6
+ metadata.gz: e81b4167a7fa446ae13d4e3bf97f4ec761e3c4d0208c0f0ce359c5a20ec2b681153ffd483b4098a4d6e799045a2298d208c014cc8b145bc65d908205ef173b01
7
+ data.tar.gz: 621306c37ab18f702f1d06815cf632f5ee166cbd2f6fb139d054b428293a0c20e377e5f0d6667b0635e9d608d2b667ee81de397e148b413bac175f673b996af3
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .swp
19
+ .ruby-version
20
+ .rbenv-gemsets
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format doc
2
+ --order random
3
+ --color
4
+ --fail-fast
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+
5
+ rvm:
6
+ - 2.2.4
7
+ - 2.3.0
8
+
9
+ before_install:
10
+ - gem update bundler
11
+
12
+ script:
13
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "serverspec", :git => "git://github.com/mizzy/serverspec.git"
7
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2017 KUSAKABE Yuya
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # serverspec-vyos-config
2
+ [![Build Status](https://travis-ci.org/higebu/serverspec-vyos-config.png)](https://travis-ci.org/higebu/serverspec-vyos-config)
3
+ [![Code Climate](https://codeclimate.com/github/higebu/serverspec-vyos-config/badges/gpa.svg)](https://codeclimate.com/github/higebu/serverspec-vyos-config)
4
+ [![Gem Version](https://badge.fury.io/rb/serverspec-vyos-config.svg)](https://badge.fury.io/rb/serverspec-vyos-config)
5
+ [![Dependency Status](https://gemnasium.com/badges/github.com/higebu/serverspec-vyos-config.svg)](https://gemnasium.com/github.com/higebu/serverspec-vyos-config)
6
+ [![Downloads](http://ruby-gem-downloads-badge.herokuapp.com/serverspec-vyos-config?type=total&style=flat)](https://rubygems.org/gems/serverspec-vyos-config)
7
+
8
+ serverspec-vyos-config is a [Serverspec](http://serverspec.org) custom resource type for [VyOS](http://vyos.net/wiki/Main_Page) config.
9
+
10
+ ## Installation
11
+
12
+ ```
13
+ $ gem install serverspec-vyos-config
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```
19
+ require_relative 'serverspec_vyos_config'
20
+
21
+ describe vyos_config('service ssh port') do
22
+ it { should be_exists }
23
+ its(:value) { should eq '22' }
24
+ end
25
+
26
+ ```
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ require 'rspec/core/rake_task'
4
+
5
+ # Immediately sync all stdout so that tools like buildbot can
6
+ # immediately load in the output.
7
+ $stdout.sync = true
8
+ $stderr.sync = true
9
+
10
+ # Change to the directory of this file.
11
+ Dir.chdir(File.expand_path("../", __FILE__))
12
+
13
+ # This installs the tasks that help with gem creation and
14
+ # publishing.
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ RSpec::Core::RakeTask.new
18
+ task :default => 'spec'
@@ -0,0 +1,2 @@
1
+ require "serverspec_vyos_config/version"
2
+ require "serverspec_vyos_config/vyos_config"
@@ -0,0 +1,3 @@
1
+ module ServerspecVyOSConfig
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,21 @@
1
+ module Serverspec
2
+ module Type
3
+ class VyosConfig < Base
4
+ @@cli = "/bin/cli-shell-api"
5
+ @@setup_session = "session_env=$(#{@@cli} getSessionEnv $PPID); eval ${session_env}; #{@@cli} setupSession;"
6
+ def exists?
7
+ res = @runner.run_command("#{@@setup_session} #{@@cli} exists #{@name}")
8
+ res.exit_status == 0
9
+ end
10
+
11
+ def value
12
+ @runner.run_command("#{@@setup_session} #{@@cli} returnValue #{@name}").stdout
13
+ end
14
+ end
15
+ def vyos_config(name)
16
+ VyosConfig.new(name)
17
+ end
18
+ end
19
+ end
20
+
21
+ include Serverspec::Type
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/serverspec_vyos_config/version', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "serverspec-vyos-config"
6
+ spec.version = ServerspecVyOSConfig::VERSION
7
+ spec.authors = ["Yuya Kusakabe"]
8
+ spec.email = ["yuya.kusakabe@gmail.com"]
9
+ spec.description = "Serverspec resource type for VyOS Config."
10
+ spec.summary = "Serverspec resource type for VyOS Config."
11
+ spec.homepage = "https://github.com/higebu/serverspec-vyos-config"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split($\)
15
+ spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.rubyforge_project = "serverspec-vyos-config"
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_runtime_dependency "rspec", "~> 3.0"
23
+ spec.add_development_dependency "rake", "~> 10.1.1"
24
+ end
@@ -0,0 +1,28 @@
1
+ require 'serverspec'
2
+
3
+ set :backend, :exec
4
+
5
+ module Specinfra
6
+ module Backend
7
+ class Exec < Base
8
+ def run_command cmd
9
+ CommandResult.new({
10
+ :stdout => ::Specinfra.configuration.stdout,
11
+ :stderr => ::Specinfra.configuration.stderr,
12
+ :exit_status => ::Specinfra.configuration.exit_status,
13
+ :exit_signal => nil,
14
+ })
15
+ end
16
+ end
17
+ class Cmd < Base
18
+ def run_command cmd
19
+ CommandResult.new({
20
+ :stdout => ::Specinfra.configuration.stdout,
21
+ :stderr => ::Specinfra.configuration.stderr,
22
+ :exit_status => ::Specinfra.configuration.exit_status,
23
+ :exit_signal => nil,
24
+ })
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'serverspec_vyos_config'
3
+
4
+ set :os, :family => 'base'
5
+
6
+ describe vyos_config('service ssh port') do
7
+ let(:exit_status) { 0 }
8
+ it { should be_exists }
9
+ let(:stdout) { "22" }
10
+ its(:value) { should eq '22' }
11
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: serverspec-vyos-config
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuya Kusakabe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 10.1.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 10.1.1
55
+ description: Serverspec resource type for VyOS Config.
56
+ email:
57
+ - yuya.kusakabe@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - lib/serverspec_vyos_config.rb
70
+ - lib/serverspec_vyos_config/version.rb
71
+ - lib/serverspec_vyos_config/vyos_config.rb
72
+ - serverspec-vyos-config.gemspec
73
+ - spec/spec_helper.rb
74
+ - spec/type/vyos_config_spec.rb
75
+ homepage: https://github.com/higebu/serverspec-vyos-config
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project: serverspec-vyos-config
95
+ rubygems_version: 2.5.2
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Serverspec resource type for VyOS Config.
99
+ test_files:
100
+ - spec/spec_helper.rb
101
+ - spec/type/vyos_config_spec.rb