Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ory/oathkeeper
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.3
Choose a base ref
...
head repository: ory/oathkeeper
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.0.4
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 21, 2017

  1. Copy the full SHA
    76e58f2 View commit details
  2. Copy the full SHA
    02e88be View commit details
Showing with 70 additions and 12 deletions.
  1. +46 −0 .circleci/config.yml
  2. +4 −1 rule/handler.go
  3. +20 −11 rule/manager_test.go
46 changes: 46 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Golang CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
build:
docker:
- image: circleci/golang:1.9
environment:
- PG_URL=postgres://test:test@localhost:5432/oathkeeper?sslmode=disable
- image: postgres:9.5
environment:
- POSTGRES_USER=test
- POSTGRES_PASSWORD=test
- POSTGRES_DB=oathkeeper

working_directory: /go/src/github.com/ory/oathkeeper
steps:
- checkout
- setup_remote_docker
- run: go get -u github.com/go-swagger/go-swagger/cmd/swagger github.com/bradfitz/goimports github.com/mattn/goveralls golang.org/x/tools/cmd/cover github.com/Masterminds/glide github.com/ory/go-acc

# Installation
- run: glide install
- run: go install github.com/ory/oathkeeper
- run: glide update
- run: go install github.com/ory/oathkeeper

# Format
- run: ./scripts/test-format.sh

# Tests
- run: go-acc -o coverage.txt $(glide novendor)
- run: go test -race -short $(glide novendor | grep -v cmd)

# See if swagger works
- run: ./scripts/run-genswag.sh

# Build and test dockerfiles
- run: docker build -t oathkeeper-proxy-travis-ci -f Dockerfile-proxy .
- run: docker build -t oathkeeper-management-travis-ci -f Dockerfile-management .
- run: docker run -d oathkeeper-proxy-travis-ci
- run: docker run -d oathkeeper-management-travis-ci

# Submit coverage details
- run: goveralls -service=circle-ci -coverprofile=coverage.txt -repotoken=$COVERALLS_REPO_TOKEN
5 changes: 4 additions & 1 deletion rule/handler.go
Original file line number Diff line number Diff line change
@@ -186,7 +186,10 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request, ps httprouter.P
}

func decodeRule(w http.ResponseWriter, r *http.Request) (*Rule, error) {
var rule jsonRule
rule := jsonRule{
MatchesMethods: []string{},
RequiredScopes: []string{},
}
if err := json.NewDecoder(r.Body).Decode(&rule); err != nil {
return nil, err
}
31 changes: 20 additions & 11 deletions rule/manager_test.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (
)

var resources []*dockertest.Resource
var pool *dockertest.Pool
var pool = new(dockertest.Pool)

func kjillAll() {
for _, resource := range resources {
@@ -121,28 +121,37 @@ func connectToPostgres(t *testing.T, managers map[string]Manager) {
func connectToPostgresDB(t *testing.T) *sqlx.DB {
var db *sqlx.DB
var err error
pool, err = dockertest.NewPool("")
if err != nil {
t.Fatalf("Could not connect to docker: %s", err)
}
var resource *dockertest.Resource

url := os.Getenv("PG_URL")
if url == "" {
pool, err = dockertest.NewPool("")
if err != nil {
t.Fatalf("Could not connect to docker: %s", err)
}

resource, err := pool.Run("postgres", "9.6", []string{"POSTGRES_PASSWORD=secret", "POSTGRES_DB=oathkeeper"})
if err != nil {
t.Fatalf("Could not start resource: %s", err)
resource, err = pool.Run("postgres", "9.6", []string{"POSTGRES_PASSWORD=secret", "POSTGRES_DB=oathkeeper"})
if err != nil {
t.Fatalf("Could not start resource: %s", err)
}

url = fmt.Sprintf("postgres://postgres:secret@localhost:%s/oathkeeper?sslmode=disable", resource.GetPort("5432/tcp"))
resources = append(resources, resource)
}

if err = pool.Retry(func() error {
var err error
db, err = sqlx.Open("postgres", fmt.Sprintf("postgres://postgres:secret@localhost:%s/oathkeeper?sslmode=disable", resource.GetPort("5432/tcp")))
db, err = sqlx.Open("postgres", url)
if err != nil {
return err
}
return db.Ping()
}); err != nil {
pool.Purge(resource)
if resource != nil {
pool.Purge(resource)
}
t.Fatalf("Could not connect to docker: %s", err)
}

resources = append(resources, resource)
return db
}