1
0
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:
Shaun Dunning
2019-09-03 17:53:37 -04:00
committed by Wes McNamee
parent 913be01848
commit a8bdfed27f
4 changed files with 120 additions and 1 deletions

View File

@ -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)
}