Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PUP-2609) Windows error on use source permissions #3226

Conversation

MikaelSmith
Copy link
Contributor

  • (PUP-2609) Make copying permissions on Win an error
  • (PUP-2609) Update Metadata default permission

@MikaelSmith MikaelSmith changed the title Task/master/pup 2609 windows error on use source permissions (PUP-2609) Windows error on use source permissions Oct 22, 2014
@MikaelSmith
Copy link
Contributor Author

@joshcooper @Iristyle @ferventcoder One of you mind taking a close look at this to make sure I've got changes to the ACL tests right?

@puppetcla
Copy link

CLA signed by all contributors.

@ferventcoder
Copy link
Contributor

@MikaelSmith I'll take a look at it.

@@ -27,7 +27,7 @@ class MetaStat

def initialize(stat, source_permissions = nil)
@stat = stat
@source_permissions_ignore = source_permissions == :ignore
@source_permissions_ignore = (!source_permissions or source_permissions == :ignore)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this isn't flow control, we should use || here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@MikaelSmith
Copy link
Contributor Author

@ferventcoder Do you care about expect {}.to vs expect {}.should?

@adrienthebo
Copy link
Contributor

RSpec 3 deprecated expect { }.should in favor of expect { }.to. We're not there yet but it's future proofing.

Copying permissions on Windows are problematic, so it isn't done. Change
the deprecation warning about source_permissions => use/use_when_creating
to an error.
@MikaelSmith MikaelSmith force-pushed the task/master/PUP-2609-Windows-error-on-use-source-permissions branch from 9b45ff2 to 7686e53 Compare October 23, 2014 23:05
expect { win_stat.owner }.to raise_error(ArgumentError)
expect { win_stat.group }.to raise_error(ArgumentError)
expect { win_stat.mode }.to raise_error(ArgumentError)
expect { Puppet::FileServing::Metadata::WindowsStat.new(stat, path, :use) }.to raise_error(ArgumentError)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the best error that can be raised? I'd prefer to scope out a little of the error text and validate it's the error we are looking for. Seeing what you did in source_spec and above this line should be emulated here. Perhaps it is not possible though. That's fine. If it can be changed, this would be the only thing holding up a merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to be more specific. I'll update it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Update Metadata's default permission model to ignore source permissions,
and remove unreachable code. Update spec tests for new behavior.
@MikaelSmith MikaelSmith force-pushed the task/master/PUP-2609-Windows-error-on-use-source-permissions branch from 7686e53 to 02bf973 Compare October 24, 2014 20:11
Puppet::Util::Windows::Security.stubs(:get_owner).with(path).raises(invalid_error)
Puppet::Util::Windows::Security.stubs(:get_group).with(path).raises(invalid_error)
Puppet::Util::Windows::Security.stubs(:get_mode).with(path).raises(invalid_error)
Puppet::Util::Windows::Security.stubs(:get_owner).with(path, :use).raises(invalid_error)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These stubs will never be called. Is it worth stubbing them out? Same question about the whole previous test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What used to call them? A test that was removed? Or have they just been orphaned?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like guards to me to ensure that those methods are not called as an artifact of testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calls to retrieve win_stat.owner/group/mode would call them unless source_permissions=:ignore was passed in. That's no longer supported, but they still serve as guards.

Edit: meant :ignore, not :use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So ignore would end up calling them?

@ferventcoder
Copy link
Contributor

I'm good with this as it is now.

ferventcoder added a commit that referenced this pull request Oct 27, 2014
…s-error-on-use-source-permissions

(PUP-2609) Windows error on use source permissions
@ferventcoder ferventcoder merged commit a52294f into puppetlabs:master Oct 27, 2014
@MikaelSmith MikaelSmith deleted the task/master/PUP-2609-Windows-error-on-use-source-permissions branch December 1, 2014 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants