Skip to content

Commit

Permalink
vendor: update to latest versions and try to resolve logrus
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas (arekkas) committed Jun 4, 2017
1 parent 62119cd commit 72fb1fb
Show file tree
Hide file tree
Showing 19 changed files with 458 additions and 33 deletions.
2 changes: 1 addition & 1 deletion client/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"

"github.com/julienschmidt/httprouter"
"github.com/ory-am/common/rand/sequence"
"github.com/ory/hydra/rand/sequence"
"github.com/ory/herodot"
"github.com/ory/hydra/firewall"
"github.com/ory/ladon"
Expand Down
2 changes: 1 addition & 1 deletion client/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/ory/hydra/pkg"
"github.com/ory/ladon"
"github.com/stretchr/testify/assert"
"gopkg.in/ory-am/dockertest.v3"
"github.com/ory/dockertest"
)

var clientManagers = map[string]Storage{}
Expand Down
2 changes: 1 addition & 1 deletion cmd/token_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/julienschmidt/httprouter"
"github.com/ory-am/common/rand/sequence"
"github.com/ory/hydra/rand/sequence"
"github.com/ory/hydra/pkg"
"github.com/spf13/cobra"
"github.com/toqueteos/webbrowser"
Expand Down
34 changes: 17 additions & 17 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import:
version: ~3.0.0
- package: github.com/go-sql-driver/mysql
version: ~1.3.0
- package: github.com/gorilla/context
version: ~1.1.0
- package: github.com/gorilla/sessions
version: ~1.1.0
- package: github.com/imdario/mergo
Expand All @@ -16,13 +18,10 @@ import:
- package: github.com/lib/pq
- package: github.com/meatballhat/negroni-logrus
- package: github.com/moul/http2curl
- package: github.com/ory-am/common
version: ~0.4.0
subpackages:
- pkg
- rand/sequence
- package: github.com/oleiade/reflections
version: ~1.0.0
- package: github.com/ory/fosite
version: ~0.9.0
version: 0.9.0
subpackages:
- compose
- handler/oauth2
Expand All @@ -33,9 +32,9 @@ import:
- package: github.com/ory/graceful
version: ~0.1.0
- package: github.com/ory/herodot
version: ~0.0.3
version: ~0.1.0
- package: github.com/ory/ladon
version: ~0.7.2
version: 0.7.2
subpackages:
- manager/memory
- manager/sql
Expand All @@ -44,14 +43,19 @@ import:
- package: github.com/pkg/errors
version: ~0.8.0
- package: github.com/pkg/profile
version: ~1.2.0
version: ~1.2.1
- package: github.com/rubenv/sql-migrate
- package: github.com/spf13/cobra
- package: github.com/spf13/viper
- package: github.com/square/go-jose
version: ~1.1.0
subpackages:
- json
- package: github.com/stretchr/testify
version: ~1.1.4
subpackages:
- assert
- require
- package: github.com/toqueteos/webbrowser
version: ~1.0.0
- package: github.com/urfave/negroni
Expand All @@ -60,11 +64,7 @@ import:
subpackages:
- clientcredentials
- package: gopkg.in/yaml.v2
testImports:
- package: gopkg.in/ory-am/dockertest.v3
version: ~3.0.7
- package: github.com/stretchr/testify
version: ~1.1.4
subpackages:
- assert
- require
testImport:
- package: github.com/bmizerany/assert
- package: github.com/ory/dockertest
version: ~3.0.7
2 changes: 1 addition & 1 deletion integration/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
"gopkg.in/ory-am/dockertest.v3"
"github.com/ory/dockertest"
)

var resources []*dockertest.Resource
Expand Down
2 changes: 1 addition & 1 deletion jwk/generator_hs256.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jwk
import (
"crypto/x509"

"github.com/ory-am/common/rand/sequence"
"github.com/ory/hydra/rand/sequence"
"github.com/pkg/errors"
"github.com/square/go-jose"
)
Expand Down
49 changes: 49 additions & 0 deletions oauth2/equalKeys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package oauth2

import "testing"
import "github.com/oleiade/reflections"
import "github.com/stretchr/testify/assert"
import "github.com/stretchr/testify/require"

func AssertObjectKeysEqual(t *testing.T, a, b interface{}, keys ...string) {
assert.True(t, len(keys) > 0, "No keys provided.")
for _, k := range keys {
c, err := reflections.GetField(a, k)
assert.Nil(t, err)
d, err := reflections.GetField(b, k)
assert.Nil(t, err)
assert.Equal(t, c, d, "%s", k)
}
}

func AssertObjectKeysNotEqual(t *testing.T, a, b interface{}, keys ...string) {
assert.True(t, len(keys) > 0, "No keys provided.")
for _, k := range keys {
c, err := reflections.GetField(a, k)
assert.Nil(t, err)
d, err := reflections.GetField(b, k)
assert.Nil(t, err)
assert.NotEqual(t, c, d, "%s", k)
}
}

func RequireObjectKeysEqual(t *testing.T, a, b interface{}, keys ...string) {
assert.True(t, len(keys) > 0, "No keys provided.")
for _, k := range keys {
c, err := reflections.GetField(a, k)
assert.Nil(t, err)
d, err := reflections.GetField(b, k)
assert.Nil(t, err)
require.Equal(t, c, d, "%s", k)
}
}
func RequireObjectKeysNotEqual(t *testing.T, a, b interface{}, keys ...string) {
assert.True(t, len(keys) > 0, "No keys provided.")
for _, k := range keys {
c, err := reflections.GetField(a, k)
assert.Nil(t, err)
d, err := reflections.GetField(b, k)
assert.Nil(t, err)
require.NotEqual(t, c, d, "%s", k)
}
}
17 changes: 17 additions & 0 deletions oauth2/equalKeys_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package oauth2

import "testing"

func TestAssertObjectsAreEqualByKeys(t *testing.T) {
type foo struct {
Name string
Body int
}
a := &foo{"foo", 1}
b := &foo{"bar", 1}
c := &foo{"baz", 3}

AssertObjectKeysEqual(t, a, a, "Name", "Body")
AssertObjectKeysNotEqual(t, a, b, "Name")
AssertObjectKeysNotEqual(t, a, c, "Name", "Body")
}
9 changes: 4 additions & 5 deletions oauth2/fosite_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

"github.com/Sirupsen/logrus"
c "github.com/ory-am/common/pkg"
"github.com/ory/fosite"
"github.com/ory/hydra/client"
"github.com/ory/hydra/integration"
Expand Down Expand Up @@ -84,7 +83,7 @@ func TestCreateGetDeleteAuthorizeCodes(t *testing.T) {

res, err := m.GetAuthorizeCodeSession(ctx, "4321", &fosite.DefaultSession{})
require.Nil(t, err)
c.AssertObjectKeysEqual(t, &defaultRequest, res, "Scopes", "GrantedScopes", "Form", "Session")
AssertObjectKeysEqual(t, &defaultRequest, res, "Scopes", "GrantedScopes", "Form", "Session")

err = m.DeleteAuthorizeCodeSession(ctx, "4321")
require.Nil(t, err)
Expand All @@ -109,7 +108,7 @@ func TestCreateGetDeleteAccessTokenSession(t *testing.T) {

res, err := m.GetAccessTokenSession(ctx, "4321", &fosite.DefaultSession{})
require.Nil(t, err)
c.AssertObjectKeysEqual(t, &defaultRequest, res, "Scopes", "GrantedScopes", "Form", "Session")
AssertObjectKeysEqual(t, &defaultRequest, res, "Scopes", "GrantedScopes", "Form", "Session")

err = m.DeleteAccessTokenSession(ctx, "4321")
require.Nil(t, err)
Expand All @@ -134,7 +133,7 @@ func TestCreateGetDeleteOpenIDConnectSession(t *testing.T) {

res, err := m.GetOpenIDConnectSession(ctx, "4321", &fosite.Request{Session: &fosite.DefaultSession{}})
require.Nil(t, err)
c.AssertObjectKeysEqual(t, &defaultRequest, res, "Scopes", "GrantedScopes", "Form", "Session")
AssertObjectKeysEqual(t, &defaultRequest, res, "Scopes", "GrantedScopes", "Form", "Session")

err = m.DeleteOpenIDConnectSession(ctx, "4321")
require.Nil(t, err)
Expand All @@ -159,7 +158,7 @@ func TestCreateGetDeleteRefreshTokenSession(t *testing.T) {

res, err := m.GetRefreshTokenSession(ctx, "4321", &fosite.DefaultSession{})
require.Nil(t, err)
c.AssertObjectKeysEqual(t, &defaultRequest, res, "Scopes", "GrantedScopes", "Form", "Session")
AssertObjectKeysEqual(t, &defaultRequest, res, "Scopes", "GrantedScopes", "Form", "Session")

err = m.DeleteRefreshTokenSession(ctx, "4321")
require.Nil(t, err)
Expand Down
26 changes: 26 additions & 0 deletions pkg/joinURL.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package pkg

import (
"fmt"
"net/url"
"path"
)

func JoinURLStrings(host string, parts ...string) string {
var trailing string

last := parts[len(parts)-1]
if last[len(last)-1:] == "/" {
trailing = "/"
}

u, err := url.Parse(host)
if err != nil {
return fmt.Sprintf("%s%s%s", path.Join(append([]string{u.Path}, parts...)...), trailing)
}

if u.Path == "" {
u.Path = "/"
}
return fmt.Sprintf("%s://%s%s%s", u.Scheme, u.Host, path.Join(append([]string{u.Path}, parts...)...), trailing)
}
33 changes: 33 additions & 0 deletions pkg/joinURL_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package pkg

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestJoinURLStrings(t *testing.T) {
for k, c := range []struct {
give []string
get string
}{
{
give: []string{"http://localhost/", "/home"},
get: "http://localhost/home",
},
{
give: []string{"http://localhost", "/home"},
get: "http://localhost/home",
},
{
give: []string{"https://localhost/", "/home"},
get: "https://localhost/home",
},
{
give: []string{"http://localhost/", "/home", "home/", "/home/"},
get: "http://localhost/home/home/home/",
},
} {
assert.Equal(t, c.get, JoinURLStrings(c.give[0], c.give[1:]...), "Case %d", k)
}
}
2 changes: 1 addition & 1 deletion pkg/secret.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package pkg

import "github.com/ory-am/common/rand/sequence"
import "github.com/ory/hydra/rand/sequence"

var secretCharSet = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-.,!$%&/()=?><")

Expand Down
5 changes: 0 additions & 5 deletions pkg/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"net/url"
"path"

"github.com/ory-am/common/pkg"
)

func CopyURL(u *url.URL) *url.URL {
Expand All @@ -13,10 +12,6 @@ func CopyURL(u *url.URL) *url.URL {
return a
}

func JoinURLStrings(host string, args ...string) string {
return pkg.JoinURL(host, args...)
}

func JoinURL(u *url.URL, args ...string) (ep *url.URL) {
ep = CopyURL(u)
ep.Path = path.Join(append([]string{ep.Path}, args...)...)
Expand Down
42 changes: 42 additions & 0 deletions rand/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# rand
A library based on crypto/rand to create random sequences, which are cryptographically strong. See: [crypto/rand](http://golang.org/pkg/crypto/rand/)

## Install

Run `go get github.com/ory-am/common/rand`

## Usage

### Create a random integer

Create a random integer using [crypto/rand.Read](http://golang.org/pkg/crypto/rand/#Read):

```
import "github.com/ory-am/common/rand/numeric"
import "fmt"
func main() {
fmt.Printf("%d", numeric.Int64())
fmt.Printf("%d", numeric.UInt64())
fmt.Printf("%d", numeric.Int32())
fmt.Printf("%d", numeric.UInt32())
}
```

### Create a random rune sequence / string

Create a random string using [crypto/rand.Read](http://golang.org/pkg/crypto/rand/#Read):

```
import "github.com/ory-am/common/rand/sequence"
import "fmt"
func main() {
allowed := []rune("abcdefghijklmnopqrstuvwxyz")
length := 10
seq, err := sequence.RuneSequence(length, allowed)
fmt.Printf("%s", seq)
fmt.Printf("%s", string(seq))
}
```
2 changes: 2 additions & 0 deletions rand/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// A library based on crypto/rand to create random sequences
package rand
Loading

0 comments on commit 72fb1fb

Please sign in to comment.