Fix existing tests
This commit is contained in:
parent
6f1c16f033
commit
d7b8506ea2
@ -266,6 +266,16 @@ func (tp *TestProvider) GetEmailAddress(session *sessions.SessionState) (string,
|
||||
return tp.EmailAddress, nil
|
||||
}
|
||||
|
||||
func (tp *TestProvider) GetUserDetails(s *sessions.SessionState) (map[string]string, error) {
|
||||
userDetails := map[string]string{}
|
||||
email, err := tp.GetEmailAddress(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
userDetails["email"] = email
|
||||
return userDetails, nil
|
||||
}
|
||||
|
||||
func (tp *TestProvider) ValidateSessionState(session *sessions.SessionState) bool {
|
||||
return tp.ValidToken
|
||||
}
|
||||
@ -412,8 +422,7 @@ func (patTest *PassAccessTokenTest) Close() {
|
||||
patTest.providerServer.Close()
|
||||
}
|
||||
|
||||
func (patTest *PassAccessTokenTest) getCallbackEndpoint() (httpCode int,
|
||||
cookie string) {
|
||||
func (patTest *PassAccessTokenTest) getCallbackEndpoint() (httpCode int, cookie string) {
|
||||
rw := httptest.NewRecorder()
|
||||
req, err := http.NewRequest("GET", "/oauth2/callback?code=callback_code&state=nonce:",
|
||||
strings.NewReader(""))
|
||||
|
@ -40,9 +40,9 @@ func TestAzureProviderDefaults(t *testing.T) {
|
||||
p.Data().LoginURL.String())
|
||||
assert.Equal(t, "https://login.microsoftonline.com/common/oauth2/token",
|
||||
p.Data().RedeemURL.String())
|
||||
assert.Equal(t, "https://graph.windows.net/me?api-version=1.6",
|
||||
assert.Equal(t, "https://graph.microsoft.com/v1.0/me",
|
||||
p.Data().ProfileURL.String())
|
||||
assert.Equal(t, "https://graph.windows.net",
|
||||
assert.Equal(t, "https://graph.microsoft.com",
|
||||
p.Data().ProtectedResource.String())
|
||||
assert.Equal(t, "",
|
||||
p.Data().ValidateURL.String())
|
||||
@ -96,9 +96,9 @@ func TestAzureSetTenant(t *testing.T) {
|
||||
p.Data().LoginURL.String())
|
||||
assert.Equal(t, "https://login.microsoftonline.com/example/oauth2/token",
|
||||
p.Data().RedeemURL.String())
|
||||
assert.Equal(t, "https://graph.windows.net/me?api-version=1.6",
|
||||
assert.Equal(t, "https://graph.microsoft.com/v1.0/me",
|
||||
p.Data().ProfileURL.String())
|
||||
assert.Equal(t, "https://graph.windows.net",
|
||||
assert.Equal(t, "https://graph.microsoft.com",
|
||||
p.Data().ProtectedResource.String())
|
||||
assert.Equal(t, "",
|
||||
p.Data().ValidateURL.String())
|
||||
@ -106,12 +106,11 @@ func TestAzureSetTenant(t *testing.T) {
|
||||
}
|
||||
|
||||
func testAzureBackend(payload string) *httptest.Server {
|
||||
path := "/me"
|
||||
query := "api-version=1.6"
|
||||
path := "/v1.0/me"
|
||||
|
||||
return httptest.NewServer(http.HandlerFunc(
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != path || r.URL.RawQuery != query {
|
||||
if r.URL.Path != path {
|
||||
w.WriteHeader(404)
|
||||
} else if r.Header.Get("Authorization") != "Bearer imaginary_access_token" {
|
||||
w.WriteHeader(403)
|
||||
|
Loading…
Reference in New Issue
Block a user