@@ -33,7 +33,10 @@ def write(arg)
3333describe Chef ::Certificate do
3434 describe "generate_signing_ca" do
3535 before ( :each ) do
36+ Chef ::Config [ :signing_ca_user ] = nil
37+ Chef ::Config [ :signing_ca_group ] = nil
3638 FileUtils . stub! ( :mkdir_p ) . and_return ( true )
39+ FileUtils . stub! ( :chown ) . and_return ( true )
3740 File . stub! ( :open ) . and_return ( true )
3841 File . stub! ( :exists? ) . and_return ( false )
3942 @ca_cert = FakeFile . new
@@ -45,9 +48,19 @@ def write(arg)
4548 Chef ::Certificate . generate_signing_ca
4649 @ca_cert . data . should =~ /BEGIN CERTIFICATE/
4750 end
48-
51+
4952 it "should generate an RSA private key" do
5053 File . should_receive ( :open ) . with ( Chef ::Config [ :signing_ca_key ] , File ::WRONLY |File ::EXCL |File ::CREAT , 0600 ) . and_yield ( @ca_key )
54+ FileUtils . should_not_receive ( :chown )
55+ Chef ::Certificate . generate_signing_ca
56+ @ca_key . data . should =~ /BEGIN RSA PRIVATE KEY/
57+ end
58+
59+ it "should generate an RSA private key with user and group" do
60+ Chef ::Config [ :signing_ca_user ] = "funky"
61+ Chef ::Config [ :signing_ca_group ] = "fresh"
62+ File . should_receive ( :open ) . with ( Chef ::Config [ :signing_ca_key ] , File ::WRONLY |File ::EXCL |File ::CREAT , 0600 ) . and_yield ( @ca_key )
63+ FileUtils . should_receive ( :chown ) . with ( Chef ::Config [ :signing_ca_user ] , Chef ::Config [ :signing_ca_group ] , Chef ::Config [ :signing_ca_key ] )
5164 Chef ::Certificate . generate_signing_ca
5265 @ca_key . data . should =~ /BEGIN RSA PRIVATE KEY/
5366 end
0 commit comments