train-juniper 0.6.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 691c9e5fe38bb5e1b021f1a79a933ffdf4c53e4a451e5524060761d009f16c20
4
- data.tar.gz: 7147093352b9ef32703242f7c8f2bad3eb25db4e91dabd843bb10dbecae904ee
3
+ metadata.gz: 4428bf34013845866814e344ce4f67460a6af1a70fc33f33641a9412fee9dccb
4
+ data.tar.gz: 40f7a51485657e5616c744fa379283c8c0dfc1dbaa6d3a307ac4e9c909884d0d
5
5
  SHA512:
6
- metadata.gz: 5253fca20205c39cdcca5defb6424f03e68178f902bfe3b8d223327f5ca1534b168f9bedbb5d9b26d9a4f48bc7727da9a725121e41ed49a99a0568f74b75dfb9
7
- data.tar.gz: dc11e4ca30b48cba807051426c12ac1120d8c9297bca9af0bcce22bb129badb4ad1f009550502d57b141255ae723ec47633c278661caf3630d8db6e500e15fd8
6
+ metadata.gz: 31d2993f5e85a04ff1c1940644242df90e1c19066339eb8be395ec1378767fce53958278318f58e1fea7a51c0ea5f0923f5447f8f204f5b374e4e8ca6e4d91bd
7
+ data.tar.gz: f0da0acd3ea9398723a62cbb5a5f73a9af010c440218a7a01f62ba2f4071eb33833d7d284b5e4b55d166f0e61c3b47988bd85cd3854dad6eb00f2155551b1dd0
data/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.6.2] - 2025-06-18
9
+
10
+ ### Fixed
11
+
12
+ - Fix Windows installation issue by relaxing FFI dependency to match InSpec 7 (>= 1.15.5, < 1.17.0) (#2)
13
+ - Fix mock mode platform detection to correctly show JunOS version instead of gem version
14
+ - Update release workflow to use trusted publishing with OIDC authentication
15
+ - Update workflows to use Ruby 3.3 for improved trusted publishing support
16
+
17
+ ### Added
18
+
19
+ - Add `mock?` method to properly support mock mode in platform detection
20
+ - Add comprehensive mock mode documentation to README
21
+
22
+ ### Changed
23
+
24
+ - Update release process documentation to reflect trusted publishing setup
25
+
26
+ ## [0.6.1] - 2025-06-18
27
+
28
+ ### Fixed
29
+
30
+ - Simplify release workflow to use API key directly
31
+
32
+ ## [0.6.0] - 2025-06-18
33
+
8
34
  ## [0.5.8] - 2025-06-18
9
35
 
10
36
  ### Fixed
data/README.md CHANGED
@@ -303,6 +303,40 @@ ping device.internal # From bastion host
303
303
  telnet device.internal 22 # Test SSH port
304
304
  ```
305
305
 
306
+ ## Mock Mode (Testing Without Hardware)
307
+
308
+ The train-juniper plugin includes a comprehensive mock mode for testing profiles without requiring physical Juniper hardware:
309
+
310
+ ```bash
311
+ # Use mock mode with InSpec detect
312
+ inspec detect -t "juniper://admin@mock-device?mock=true"
313
+
314
+ # Output shows mocked JunOS platform:
315
+ # Name: juniper
316
+ # Families: bsd
317
+ # Release: 12.1X47-D15.4
318
+ ```
319
+
320
+ For programmatic usage in tests:
321
+ ```ruby
322
+ require 'train'
323
+ connection = Train.create('juniper',
324
+ host: 'test-device',
325
+ user: 'admin',
326
+ mock: true
327
+ )
328
+
329
+ # Mock mode returns predefined responses
330
+ result = connection.run_command('show version')
331
+ # => Returns mock JunOS version output
332
+ ```
333
+
334
+ Mock mode provides:
335
+ - ✅ Realistic JunOS command outputs
336
+ - ✅ Platform detection (JunOS 12.1X47-D15.4)
337
+ - ✅ Error simulation for negative testing
338
+ - ✅ Fast execution for CI/CD pipelines
339
+
306
340
  ## Development
307
341
 
308
342
  ### Requirements
@@ -66,9 +66,9 @@ module TrainPlugins
66
66
 
67
67
  super(@options)
68
68
 
69
- # Establish SSH connection to Juniper device (unless in mock mode)
69
+ # Establish SSH connection to Juniper device (unless in mock mode or skip_connect)
70
70
  @logger.debug('Attempting to connect to Juniper device...')
71
- connect unless @options[:mock]
71
+ connect unless @options[:mock] || @options[:skip_connect]
72
72
  end
73
73
 
74
74
  # Secure string representation (never expose credentials)
@@ -226,11 +226,18 @@ module TrainPlugins
226
226
 
227
227
  # Check if SSH connection is active
228
228
  def connected?
229
+ return true if @options[:mock]
230
+
229
231
  !@ssh_session.nil?
230
232
  rescue StandardError
231
233
  false
232
234
  end
233
235
 
236
+ # Check if running in mock mode
237
+ def mock?
238
+ @options[:mock] == true
239
+ end
240
+
234
241
  # Test connection and configure JunOS session
235
242
  def test_and_configure_session
236
243
  @logger.debug('Testing SSH connection and configuring JunOS session')
@@ -52,16 +52,28 @@ module TrainPlugins::Juniper
52
52
  return @detected_junos_version if defined?(@detected_junos_version)
53
53
 
54
54
  # Only try version detection if we have an active connection
55
- return @detected_junos_version = nil unless respond_to?(:run_command_via_connection)
56
- return @detected_junos_version = nil if @options&.dig(:mock) # Skip in mock mode
55
+ unless respond_to?(:run_command_via_connection)
56
+ logger&.debug('run_command_via_connection not available yet')
57
+ return @detected_junos_version = nil
58
+ end
59
+
60
+ logger&.debug("Mock mode: #{@options&.dig(:mock)}, Connected: #{connected?}")
57
61
 
58
62
  begin
59
63
  # Check if connection is ready before running commands
60
- return @detected_junos_version = nil unless connected?
64
+ unless connected?
65
+ logger&.debug('Not connected, skipping version detection')
66
+ return @detected_junos_version = nil
67
+ end
61
68
 
62
69
  # Execute 'show version' command to get JunOS information
70
+ logger&.debug("Running 'show version' command")
63
71
  result = run_command_via_connection('show version')
64
- return @detected_junos_version = nil unless result&.exit_status&.zero?
72
+
73
+ unless result&.exit_status&.zero?
74
+ logger&.debug("Command failed with exit status: #{result&.exit_status}")
75
+ return @detected_junos_version = nil
76
+ end
65
77
 
66
78
  # Cache the result for architecture detection to avoid duplicate calls
67
79
  @cached_show_version_result = result
@@ -112,7 +124,6 @@ module TrainPlugins::Juniper
112
124
 
113
125
  # Only try architecture detection if we have an active connection
114
126
  return @detected_junos_architecture = nil unless respond_to?(:run_command_via_connection)
115
- return @detected_junos_architecture = nil if @options&.dig(:mock) # Skip in mock mode
116
127
 
117
128
  begin
118
129
  # Check if connection is ready before running commands
@@ -7,6 +7,6 @@
7
7
 
8
8
  module TrainPlugins
9
9
  module Juniper
10
- VERSION = '0.6.0'
10
+ VERSION = '0.6.2'
11
11
  end
12
12
  end
@@ -67,6 +67,7 @@ Gem::Specification.new do |spec|
67
67
  # SSH connectivity dependencies - match train-core's exact version range
68
68
  spec.add_dependency 'net-ssh', '>= 2.9', '< 8.0'
69
69
 
70
- # Force compatible FFI version to avoid conflicts with InSpec
71
- spec.add_dependency 'ffi', '~> 1.16.0'
70
+ # FFI dependency - required by train-core
71
+ # Match InSpec 7's FFI version range for compatibility
72
+ spec.add_dependency 'ffi', '>= 1.15.5', '< 1.17.0'
72
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train-juniper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MITRE Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-18 00:00:00.000000000 Z
11
+ date: 2025-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train-core
@@ -48,16 +48,22 @@ dependencies:
48
48
  name: ffi
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.15.5
54
+ - - "<"
52
55
  - !ruby/object:Gem::Version
53
- version: 1.16.0
56
+ version: 1.17.0
54
57
  type: :runtime
55
58
  prerelease: false
56
59
  version_requirements: !ruby/object:Gem::Requirement
57
60
  requirements:
58
- - - "~>"
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.15.5
64
+ - - "<"
59
65
  - !ruby/object:Gem::Version
60
- version: 1.16.0
66
+ version: 1.17.0
61
67
  description: Provides SSH connectivity to Juniper Networks devices running JunOS for
62
68
  InSpec compliance testing and infrastructure inspection. Supports platform detection,
63
69
  command execution, and configuration file access.
@@ -108,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
114
  - !ruby/object:Gem::Version
109
115
  version: '0'
110
116
  requirements: []
111
- rubygems_version: 3.3.27
117
+ rubygems_version: 3.5.22
112
118
  signing_key:
113
119
  specification_version: 4
114
120
  summary: Train transport for Juniper Networks JunOS devices