mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-06-14 23:45:03 +02:00
feat: add support for JWT auth with qsh needed by add-ons
This commit is contained in:
committed by
Wes McNamee
parent
913be01848
commit
a8bdfed27f
24
jira_test.go
24
jira_test.go
@ -612,3 +612,27 @@ func TestCookieAuthTransport_SessionObject_DoesNotExist(t *testing.T) {
|
||||
req, _ := basicAuthClient.NewRequest("GET", ".", nil)
|
||||
basicAuthClient.Do(req, nil)
|
||||
}
|
||||
|
||||
func TestJWTAuthTransport_HeaderContainsJWT(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
sharedSecret := []byte("ssshh,it's a secret")
|
||||
issuer := "add-on.key"
|
||||
|
||||
jwtTransport := &JWTAuthTransport{
|
||||
Secret: sharedSecret,
|
||||
Issuer: issuer,
|
||||
}
|
||||
|
||||
testMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
// look for the presence of the JWT in the header
|
||||
val := r.Header.Get("Authorization")
|
||||
if !strings.Contains(val, "JWT ") {
|
||||
t.Errorf("request does not contain JWT in the Auth header")
|
||||
}
|
||||
})
|
||||
|
||||
jwtClient, _ := NewClient(jwtTransport.Client(), testServer.URL)
|
||||
jwtClient.Issue.Get("TEST-1", nil)
|
||||
}
|
||||
|
Reference in New Issue
Block a user