Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Remove default value for shared - Fixes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
leoarnold committed Nov 22, 2017
1 parent 5ad8c75 commit 72a349a
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 11 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 2017-11-21 - Bugfix release 2.0.2

Published at [Puppet Forge](https://forge.puppet.com/leoarnold/cups/2.0.2)
and [GitHub](https://github.com/leoarnold/puppet-cups/releases/tag/2.0.2).

### Summary

This release fixes a conflict when using remotely shared queues.

### Bugfixes

- Removed the default value `shared => false` for type `cups_queue`
in order to comply with [CUPS #4766](https://github.com/apple/cups/issues/4766)

## 2017-11-16 - Official Approval by Puppet Inc

We are proud to announce that Puppet Inc [officially approved](https://tickets.puppetlabs.com/browse/MODULES-5903)
version 2.0.1 of this module.

## 2017-11-09 - Service release 2.0.1

Published at [Puppet Forge](https://forge.puppet.com/leoarnold/cups/2.0.1)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ Installs and manages CUPS print queues.
on the node for a list of all supported options for the given queue, and `lpoptions -p [queue_name] -l`
to see a list of available values for the most commonly used printer specific options.

* `shared`: Boolean value specifying whether to share this queue on the network. Default is `false`.
* `shared`: Boolean value specifying whether to share this queue on the network.

##### Class-only attributes

Expand Down
3 changes: 1 addition & 2 deletions lib/puppet/type/cups_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,9 @@ def should_to_s(newvalue)
end

newproperty(:shared) do
desc 'Boolean value specifying whether to share this queue on the network. Default is `false`.'
desc 'Boolean value specifying whether to share this queue on the network.'

newvalues(:true, :false)
defaultto(:false)
end

newproperty(:uri) do
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leoarnold-cups",
"version": "2.0.1",
"version": "2.0.2",
"author": "Leo Arnold",
"summary": "Puppet module for the Common Unix Printing System (CUPS)",
"license": "MIT",
Expand Down
75 changes: 75 additions & 0 deletions spec/acceptance/puppet/cups_issue_4766_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

# See also: https://github.com/leoarnold/puppet-cups/issues/28
RSpec.describe 'Circumventing CUPS issue #4766' do
before(:all) do
ensure_cups_is_running
end

context 'ensuring a queue' do
context "when is shared via IPP by some remote host and 'shared'" do
context 'is not specified' do
before(:all) do
purge_all_queues
end

manifest = <<-MANIFEST
cups_queue { 'Office':
ensure => 'printer',
uri => 'ipp://192.168.10.20/printers/Office',
}
MANIFEST

it 'applies changes' do
apply_manifest(manifest, expect_changes: true)
end

it 'is idempotent' do
apply_manifest(manifest, catch_changes: true)
end
end

context '=> true' do
before(:all) do
purge_all_queues
end

manifest = <<-MANIFEST
cups_queue { 'Office':
ensure => 'printer',
uri => 'ipp://192.168.10.20/printers/Office',
shared => true
}
MANIFEST

it 'it fails to apply changes' do
command = apply_manifest(manifest, expect_failures: true)

expect(command.stderr).to include('printer-is-shared for remote queues')
end
end

context '=> false' do
before(:all) do
purge_all_queues
end

manifest = <<-MANIFEST
cups_queue { 'Office':
ensure => 'printer',
uri => 'ipp://192.168.10.20/printers/Office',
shared => false
}
MANIFEST

it 'it fails to apply changes' do
command = apply_manifest(manifest, expect_failures: true)

expect(command.stderr).to include('printer-is-shared for remote queues')
end
end
end
end
end
2 changes: 0 additions & 2 deletions spec/unit/puppet/provider/cups_queue/cups_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
it 'installs the class with default values' do
expect(@provider).to receive(:lpadmin).with('-E', '-p', 'Office', '-c', 'GroundFloor')
expect(@provider).to receive(:lpadmin).with('-E', '-p', 'Warehouse', '-c', 'GroundFloor')
expect(@provider).to receive(:lpadmin).with('-E', '-p', 'GroundFloor', '-o', 'printer-is-shared=false')

@provider.create_class
end
Expand Down Expand Up @@ -137,7 +136,6 @@
allow(@provider).to receive(:lpadmin).with('-E', '-x', 'Office')
expect(@provider).to receive(:lpadmin).with('-E', '-p', 'Office', '-v', 'file:///dev/null')
expect(@provider).to receive(:lpadmin).with('-E', '-p', 'Office', switch[method], manifest[method]) if method
expect(@provider).to receive(:lpadmin).with('-E', '-p', 'Office', '-o', 'printer-is-shared=false')
expect(@provider).to receive(:check_make_and_model)

@provider.create_printer
Expand Down
5 changes: 0 additions & 5 deletions spec/unit/puppet/type/cups_queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,6 @@
expect(type.attrclass(:shared).doc.length).to be > 20
end

it "defaults to 'false'" do
resource = type.new(name: 'Office')
expect(resource[:shared]).to eq(:false)
end

it 'accepts boolean values' do
@resource[:shared] = :true
expect(@resource[:shared]).to eq(:true)
Expand Down

0 comments on commit 72a349a

Please sign in to comment.