Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
3ecf90b6
H
hub
项目概览
github
/
hub
10 个月 前同步成功
通知
3
Star
22523
Fork
2406
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3ecf90b6
编写于
12月 30, 2013
作者:
J
Jingwen Owen Ou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Get 2fa cucumber tests going
上级
8e87249a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
53 addition
and
11 deletion
+53
-11
Godeps/Godeps.json
Godeps/Godeps.json
+3
-3
Godeps/_workspace/src/github.com/jingweno/go-octokit/octokit/error.go
...space/src/github.com/jingweno/go-octokit/octokit/error.go
+1
-1
Godeps/_workspace/src/github.com/jingweno/go-octokit/octokit/error_test.go
.../src/github.com/jingweno/go-octokit/octokit/error_test.go
+34
-0
Godeps/_workspace/src/github.com/lostisland/go-sawyer/script/fmt
..._workspace/src/github.com/lostisland/go-sawyer/script/fmt
+8
-1
Godeps/_workspace/src/github.com/lostisland/go-sawyer/script/test
...workspace/src/github.com/lostisland/go-sawyer/script/test
+5
-2
github/configs.go
github/configs.go
+2
-4
未找到文件。
Godeps/Godeps.json
浏览文件 @
3ecf90b6
...
...
@@ -35,8 +35,8 @@
},
{
"ImportPath"
:
"github.com/jingweno/go-octokit/octokit"
,
"Comment"
:
"v0.4.0-4
1-g85bc6b5
"
,
"Rev"
:
"
74f0495a72d8a2dfce059ebf718fd60dd3800f41
"
"Comment"
:
"v0.4.0-4
6-g30737cb
"
,
"Rev"
:
"
30737cb1e9207e1a7633e3d7539951c5c3d93058
"
},
{
"ImportPath"
:
"github.com/jtacoma/uritemplates"
,
...
...
@@ -58,7 +58,7 @@
},
{
"ImportPath"
:
"github.com/lostisland/go-sawyer"
,
"Rev"
:
"
ec1b99a1915d53f09d40d0c87caf60460b7f8728
"
"Rev"
:
"
cb3f837f5ac26e080a9002dcb4d2e8472e623916
"
}
]
}
Godeps/_workspace/src/github.com/jingweno/go-octokit/octokit/error.go
浏览文件 @
3ecf90b6
...
...
@@ -118,7 +118,7 @@ func getResponseErrorType(resp *http.Response) ResponseErrorType {
case
code
==
http
.
StatusUnauthorized
:
header
:=
resp
.
Header
.
Get
(
"X-GitHub-OTP"
)
r
:=
regexp
.
MustCompile
(
`(?i)required; (\
\
w+)`
)
r
:=
regexp
.
MustCompile
(
`(?i)required; (\w+)`
)
if
r
.
MatchString
(
header
)
{
return
ErrorOneTimePasswordRequired
}
...
...
Godeps/_workspace/src/github.com/jingweno/go-octokit/octokit/error_test.go
浏览文件 @
3ecf90b6
...
...
@@ -26,6 +26,40 @@ func TestResponseError_Error_400(t *testing.T) {
assert
.
Equal
(
t
,
ErrorBadRequest
,
e
.
Type
)
}
func
TestResponseError_Error_401
(
t
*
testing
.
T
)
{
setup
()
defer
tearDown
()
mux
.
HandleFunc
(
"/error"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
head
:=
w
.
Header
()
head
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
respondWith
(
w
,
`{"message":"Unauthorized"}`
)
})
req
,
_
:=
client
.
NewRequest
(
"error"
)
_
,
err
:=
req
.
Get
(
nil
)
assert
.
Tf
(
t
,
strings
.
Contains
(
err
.
Error
(),
"401 - Unauthorized"
),
"%s"
,
err
.
Error
())
e
:=
err
.
(
*
ResponseError
)
assert
.
Equal
(
t
,
ErrorUnauthorized
,
e
.
Type
)
mux
.
HandleFunc
(
"/error_2fa"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
head
:=
w
.
Header
()
head
.
Set
(
"Content-Type"
,
"application/json"
)
head
.
Set
(
"X-GitHub-OTP"
,
"required; app"
)
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
respondWith
(
w
,
`{"message":"Unauthorized"}`
)
})
req
,
_
=
client
.
NewRequest
(
"error_2fa"
)
_
,
err
=
req
.
Get
(
nil
)
assert
.
Tf
(
t
,
strings
.
Contains
(
err
.
Error
(),
"401 - Unauthorized"
),
"%s"
,
err
.
Error
())
e
=
err
.
(
*
ResponseError
)
assert
.
Equal
(
t
,
ErrorOneTimePasswordRequired
,
e
.
Type
)
}
func
TestResponseError_Error_422_error
(
t
*
testing
.
T
)
{
setup
()
defer
tearDown
()
...
...
Godeps/_workspace/src/github.com/lostisland/go-sawyer/script/fmt
浏览文件 @
3ecf90b6
#!/bin/bash
gofmt
-w
-l
"
$@
"
*
.go
gofmt
-w
-l
*
.go ./mediatype
# don't run gofmt in these directories
ignored
=(
/bin/ /docs/ /log/ /script/ /tmp/
)
for
i
in
*
/
;
do
if
[[
!
${
ignored
[*]
}
=
~
"/
$i
"
]]
;
then
gofmt
-w
-l
"
$@
"
"
${
i
%?
}
"
fi
done
Godeps/_workspace/src/github.com/lostisland/go-sawyer/script/test
浏览文件 @
3ecf90b6
script/fmt
go test -race -v "$@" ./mediatype
go test -race -v "$@" .
packages=". ./hypermedia ./mediatype ./mediaheader"
go test -i $packages
go test -race -v $packages
github/configs.go
浏览文件 @
3ecf90b6
...
...
@@ -5,11 +5,11 @@ import (
"fmt"
"github.com/howeyc/gopass"
"github.com/jingweno/gh/utils"
"github.com/jingweno/go-octokit/octokit"
"io"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strconv"
)
...
...
@@ -37,10 +37,8 @@ func (c *Configs) PromptFor(host string) *Credentials {
// Create Client with a stub Credentials
client
:=
&
Client
{
Credentials
:
&
Credentials
{
Host
:
host
}}
token
,
err
:=
client
.
FindOrCreateToken
(
user
,
pass
,
""
)
// TODO: return a two-factor error
if
err
!=
nil
{
re
:=
regexp
.
MustCompile
(
"two-factor authentication OTP code"
)
if
re
.
MatchString
(
fmt
.
Sprintf
(
"%s"
,
err
))
{
if
re
,
ok
:=
err
.
(
*
octokit
.
ResponseError
);
ok
&&
re
.
Type
==
octokit
.
ErrorOneTimePasswordRequired
{
code
:=
c
.
PromptForOTP
()
token
,
err
=
client
.
FindOrCreateToken
(
user
,
pass
,
code
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录