-
Notifications
You must be signed in to change notification settings - Fork 932
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
Ssh key support #343
Ssh key support #343
Conversation
@awlx no tests for this? 😢 |
Sorry, was a quick fix to get it finally working. Tests will follow when I have time. And tbh. First time I use ruby, no clue how this tests work ;). |
@awlx I haven't test this, but it should be close 😉 - it "will push to the remote repository using ssh" do
- Oxidized.config.hooks.github_repo_hook.remote_repo = 'git@github.com:username/foo.git'
- Rugged::Credentials::SshKeyFromAgent.expects(:new).with(username: 'git').returns(credentials)
- gr.cfg = Oxidized.config.hooks.github_repo_hook
- gr.run_hook(ctx).must_equal true
+ describe "will push to the remote repository using ssh" do
+ before do
+ Oxidized.config.hooks.github_repo_hook.remote_repo = 'git@github.com:username/foo.git'
+ Oxidized.config.hooks.github_repo_hook.pubkey = 'pubkey'
+ Oxidized.config.hooks.github_repo_hook.privkey = 'privkey'
+ end
+
+ it "using credentials" do
+ Rugged::Credentials::SshKeyFromAgent.expects(:new).with(username: 'git').returns(credentials)
+ gr.cfg = Oxidized.config.hooks.github_repo_hook
+ gr.run_hook(ctx).must_equal true
+ end
+
+ it "using public and private keys" do
+ File.expects(:expand_path).with('pubkey').returns('/pubkey')
+ File.expects(:expand_path).with('privkey').returns('/privkey')
+
+ Rugged::Credentials::SshKey.expects(:new).with(username: 'git', publickey: '/pubkey', privatekey: '/privkey').returns(credentials)
+ gr.cfg = Oxidized.config.hooks.github_repo_hook
+ gr.run_hook(ctx).must_equal true
+ end |
@awlx another thing, what do you think of using the same keys that Rugged use: /cc @ytti + @ElvinEfendi |
Feel free, also thought about it. But I am lazy and so short config options are better ;). |
@danilopopeye publickey and privatekey are probably more descriptive yes. |
Fixed the variable names. |
@awlx let me know if you have problem with the tests 😃 |
@danilopopeye how do I test if they work the way I expect them to ? :D |
@awlx the other comment I've made, already does this. it "using public and private keys" do
# this line here
Rugged::Credentials::SshKey.expects(:new).with(username: 'git', publickey: '/pubkey', privatekey: '/privkey').returns(credentials)
gr.cfg = Oxidized.config.hooks.github_repo_hook
gr.run_hook(ctx).must_equal true
end The line I marked, tests the class Have I made sense? |
Yeah, that makes sense. My question was more "how do I test the test?". |
Oh, sorry! Must have needing more ☕! That diff is for the After that, just run |
👍 I also think we should keep it consistent with Rugged's keys. |
It's already renamed and merged :). Tests will follow soon. THX for the feedback! |
Adds the functionality to provide a ssh public and privatekey to use for SSH GIT connect.