Skip to content

Commit 601dfce

Browse files
committed
Add two factor spec.
1 parent accba7a commit 601dfce

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# encoding: utf-8
2+
3+
require 'spec_helper'
4+
5+
RSpec.describe Github::Client::Authorizations, 'two-factor' do
6+
let(:basic_auth) { 'login:password' }
7+
let(:host) { "https://#{basic_auth}@api.github.com" }
8+
9+
it "fails with known OTP error" do
10+
stub_get("/authorizations/1", host).to_return(
11+
status: 401,
12+
headers: {
13+
content_type: 'application/json',
14+
'X-GitHub-OTP' => 'required; sms'
15+
},
16+
body: {message: "Require two-factor authentication OTP token."}
17+
)
18+
expect {
19+
described_class.new(basic_auth: 'login:password').get(1)
20+
}.to raise_error(Github::Error::Unauthorized, /Require two-factor/)
21+
end
22+
end

0 commit comments

Comments
 (0)