Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
6475ce1f
Commit
6475ce1f
authored
Oct 27, 2017
by
Eric Chiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connector/oidc: remove test that talks to the internet
parent
3d65b774
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
98 deletions
+0
-98
oidc_test.go
connector/oidc/oidc_test.go
+0
-98
No files found.
connector/oidc/oidc_test.go
View file @
6475ce1f
package
oidc
import
(
"net/url"
"os"
"reflect"
"testing"
"github.com/coreos/dex/connector"
"github.com/sirupsen/logrus"
)
func
TestKnownBrokenAuthHeaderProvider
(
t
*
testing
.
T
)
{
...
...
@@ -29,95 +23,3 @@ func TestKnownBrokenAuthHeaderProvider(t *testing.T) {
}
}
}
func
TestOidcConnector_LoginURL
(
t
*
testing
.
T
)
{
logger
:=
&
logrus
.
Logger
{
Out
:
os
.
Stderr
,
Formatter
:
&
logrus
.
TextFormatter
{
DisableColors
:
true
},
Level
:
logrus
.
DebugLevel
,
}
tests
:=
[]
struct
{
scopes
connector
.
Scopes
hostedDomains
[]
string
wantScopes
string
wantHdParam
string
}{
{
connector
.
Scopes
{},
[]
string
{
"example.com"
},
"openid profile email"
,
"example.com"
,
},
{
connector
.
Scopes
{},
[]
string
{
"mydomain.org"
,
"example.com"
},
"openid profile email"
,
"*"
,
},
{
connector
.
Scopes
{},
[]
string
{},
"openid profile email"
,
""
,
},
{
connector
.
Scopes
{
OfflineAccess
:
true
},
[]
string
{},
"openid profile email"
,
""
,
},
}
callback
:=
"https://dex.example.com/callback"
state
:=
"secret"
for
_
,
test
:=
range
tests
{
config
:=
&
Config
{
Issuer
:
"https://accounts.google.com"
,
ClientID
:
"client-id"
,
ClientSecret
:
"client-secret"
,
RedirectURI
:
"https://dex.example.com/callback"
,
HostedDomains
:
test
.
hostedDomains
,
}
conn
,
err
:=
config
.
Open
(
"oidc"
,
logger
)
if
err
!=
nil
{
t
.
Errorf
(
"failed to open connector: %v"
,
err
)
continue
}
loginURL
,
err
:=
conn
.
(
connector
.
CallbackConnector
)
.
LoginURL
(
test
.
scopes
,
callback
,
state
)
if
err
!=
nil
{
t
.
Errorf
(
"failed to get login URL: %v"
,
err
)
continue
}
actual
,
err
:=
url
.
Parse
(
loginURL
)
if
err
!=
nil
{
t
.
Errorf
(
"failed to parse login URL: %v"
,
err
)
continue
}
wanted
,
_
:=
url
.
Parse
(
"https://accounts.google.com/o/oauth2/v2/auth"
)
wantedQuery
:=
&
url
.
Values
{}
wantedQuery
.
Set
(
"client_id"
,
config
.
ClientID
)
wantedQuery
.
Set
(
"redirect_uri"
,
config
.
RedirectURI
)
wantedQuery
.
Set
(
"response_type"
,
"code"
)
wantedQuery
.
Set
(
"state"
,
"secret"
)
wantedQuery
.
Set
(
"scope"
,
test
.
wantScopes
)
if
test
.
wantHdParam
!=
""
{
wantedQuery
.
Set
(
"hd"
,
test
.
wantHdParam
)
}
wanted
.
RawQuery
=
wantedQuery
.
Encode
()
if
!
reflect
.
DeepEqual
(
actual
,
wanted
)
{
t
.
Errorf
(
"Wanted %v, got %v"
,
wanted
,
actual
)
}
}
}
//func TestOidcConnector_HandleCallback(t *testing.T) {
// logger := &logrus.Logger{
// Out: os.Stderr,
// Formatter: &logrus.TextFormatter{DisableColors: true},
// Level: logrus.DebugLevel,
// }
//
// tests := []struct {
//
// }
//}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment