From faffde45e6fc90a31b2aaa085999e01e2ce9856a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohnic=CC=81?= Date: Wed, 18 Jul 2012 23:18:08 +0200 Subject: [PATCH] mode for ~/.config/hub is 0600 now Fixes #120 --- features/authentication.feature | 1 + features/steps.rb | 7 +++++++ lib/hub/github_api.rb | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/features/authentication.feature b/features/authentication.feature index 8d8f9dcb..cdba73ed 100644 --- a/features/authentication.feature +++ b/features/authentication.feature @@ -22,6 +22,7 @@ Feature: OAuth authentication And the output should contain "github.com password for mislav (never stored):" And the exit status should be 0 And the file "../home/.config/hub" should contain "oauth_token: OTOKEN" + And the file "../home/.config/hub" should have mode "0600" Scenario: Ask for username & password, re-use existing authorization Given the GitHub API server: diff --git a/features/steps.rb b/features/steps.rb index 55a7b01d..1607556f 100644 --- a/features/steps.rb +++ b/features/steps.rb @@ -124,3 +124,10 @@ Then /^there should be no "([^"]*)" remote$/ do |remote_name| remotes = run_silent('git remote').split("\n") remotes.should_not include(remote_name) end + +Then /^the file "([^"]*)" should have mode "([^"]*)"$/ do |file, expected_mode| + prep_for_fs_check do + mode = File.stat(file).mode + mode.to_s(8).should =~ /#{expected_mode}$/ + end +end diff --git a/lib/hub/github_api.rb b/lib/hub/github_api.rb index 6434a8ea..898eee92 100644 --- a/lib/hub/github_api.rb +++ b/lib/hub/github_api.rb @@ -297,7 +297,7 @@ module Hub def save FileUtils.mkdir_p File.dirname(@filename) - File.open(@filename, 'w') {|f| f << YAML.dump(@data) } + File.open(@filename, 'w', 0600) {|f| f << YAML.dump(@data) } end end -- GitLab