Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor daos #13

Closed
wants to merge 79 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
bcf87ba
Start refactoring model tests...
thibaultcha Jan 23, 2015
8f7f02d
breaking everything
thibaultcha Jan 23, 2015
2cdad66
Custom validate functions (with DAO) test
thibaultcha Jan 23, 2015
a1d9bd3
Proper model persistence tests + update uses insert_or_update
thibaultcha Jan 23, 2015
fed2e87
Models tests for all DAOs
thibaultcha Jan 24, 2015
19ff9f3
Trying to make something out of this mess after all
thibaultcha Jan 24, 2015
aad2f50
Refactoring cassandra DAO + getting rid of models
thibaultcha Jan 28, 2015
c234d5c
Remove orderedPairs that we actually don't use
thibaultcha Jan 28, 2015
6e99398
Update validation tests
thibaultcha Jan 28, 2015
d7db0fc
Drop deprecated tests (models) + better structure
thibaultcha Jan 28, 2015
60164de
Migrations now accept a custom keyspace parameter.
thibaultcha Jan 29, 2015
745a8d6
Plugins insert + schemas.lua for validation/serialization
thibaultcha Jan 29, 2015
283cd0c
Plugins id is now a composite primary key
thibaultcha Jan 29, 2015
b965728
WIP Cassandra DAO
thibaultcha Jan 30, 2015
24914f7
KONG
thibaultcha Jan 30, 2015
d61c016
Cassandra UDATE with constraints.
thibaultcha Feb 2, 2015
c548bb3
Cassandra DELETE (by id) + tests
thibaultcha Feb 3, 2015
798ef81
SELECT + describe_all_collections testing helper
thibaultcha Feb 3, 2015
c742c58
:warning: Bad :warning: :find_by_keys()
thibaultcha Feb 3, 2015
0bd277b
Fix valid DELETE test not actually testing
thibaultcha Feb 3, 2015
e2906cc
Document the base_dao
thibaultcha Feb 3, 2015
c112a3d
Prevent exceptional test failing case for plugin insert
thibaultcha Feb 3, 2015
d08e916
Only allow dynamic querying on indexed fields
thibaultcha Feb 4, 2015
a4d4de0
Deserialization of SELECT results (type "ROWS")
thibaultcha Feb 4, 2015
d0a921b
Test if all unique/exist schema properties have statements
thibaultcha Feb 4, 2015
70162d8
Merge branch 'master' into refactor-daos
subnetmarco Feb 4, 2015
f3a4423
Removing models work in progress
subnetmarco Feb 5, 2015
7baa957
refactoring
subnetmarco Feb 5, 2015
decb1e7
Metrics DAO. increment/select/delete + tests
thibaultcha Feb 5, 2015
059704d
Cleaning up some obsolete code
thibaultcha Feb 5, 2015
ea726ab
Cleanup
thibaultcha Feb 6, 2015
c8233a0
Metrics don't use encode_cassandra_values ++speed
thibaultcha Feb 6, 2015
501665e
Add unsupported metrics methods
thibaultcha Feb 6, 2015
8afda2a
Cleanup
thibaultcha Feb 6, 2015
21f5004
Fixing controllersgs
subnetmarco Feb 6, 2015
153c019
Merge branch 'refactor-daos' of github.com:Mashape/lua-resty-apenode …
subnetmarco Feb 6, 2015
494821e
fixing test and base DAO check
subnetmarco Feb 6, 2015
d1e8b4a
enum check
subnetmarco Feb 6, 2015
a6ac3f4
My cassandra is better :3
thibaultcha Feb 7, 2015
3806593
wip
subnetmarco Feb 7, 2015
57141cd
Merge branch 'refactor-daos' of github.com:Mashape/lua-resty-apenode …
subnetmarco Feb 7, 2015
5516b50
Schema validation against a function
thibaultcha Feb 7, 2015
f648a83
refactoring plugins
subnetmarco Feb 7, 2015
ddb20a6
adding constant
subnetmarco Feb 7, 2015
41776f5
Fixing metrics tests now that we have response metadata
thibaultcha Feb 7, 2015
ae3574f
Yay put back metrics in Faker entities
thibaultcha Feb 7, 2015
5e6f0c5
Faker now randomly select foreign entities from previous inserts
thibaultcha Feb 9, 2015
79703da
DAO pagination + tests + test fix + Faker improvements
thibaultcha Feb 10, 2015
5c40a99
Rename project to Kong.
thibaultcha Feb 10, 2015
e6a681e
Cleanup
thibaultcha Feb 10, 2015
e25aaa0
Replace DAO rows result `meta` with `next_page`
thibaultcha Feb 10, 2015
524da9c
Distinguish base_dao private/public interface
thibaultcha Feb 10, 2015
40caed7
wip controllers
subnetmarco Feb 10, 2015
fd7d034
Merge branch 'refactor-daos' of github.com:Mashape/kong into refactor…
subnetmarco Feb 10, 2015
e817c92
fixes bug in unique check when field is not required and nil
subnetmarco Feb 10, 2015
bf73e0e
fixes meta in data
subnetmarco Feb 10, 2015
d22fffe
fixing empty array in controllers
subnetmarco Feb 10, 2015
ab9d5ca
test web now work
subnetmarco Feb 10, 2015
4ea11b6
Distinguish schema from Cassandra errors in DAO #1
thibaultcha Feb 10, 2015
c786ccd
Distinguish schema/unique/exists error types
thibaultcha Feb 11, 2015
0acf902
wip
subnetmarco Feb 11, 2015
a628e19
Merge branch 'refactor-daos' of github.com:Mashape/kong into refactor…
subnetmarco Feb 11, 2015
34f84c9
controller
subnetmarco Feb 11, 2015
a684060
Check for uuid validation in cassandra DAO
thibaultcha Feb 11, 2015
1441788
fixing UUID regex
subnetmarco Feb 11, 2015
a624feb
Introducing constants.lua
thibaultcha Feb 11, 2015
bbcab12
Oops
thibaultcha Feb 11, 2015
9435f94
fixing bugs in plugins and adding enabled field
subnetmarco Feb 11, 2015
a332304
more tests and bugfixes
subnetmarco Feb 12, 2015
929a7ae
checking for plugin enabled
subnetmarco Feb 12, 2015
f36cd4a
Useless sleep
thibaultcha Feb 12, 2015
1dcd56c
Schema validation checks for nil, not for 'not'
thibaultcha Feb 13, 2015
9dd4c0a
Run tests with lua_code_cache on
thibaultcha Feb 13, 2015
1af7397
"immutable" schema property and more plugin tests
thibaultcha Feb 13, 2015
ef7818c
Revert cosocket premature switch
thibaultcha Feb 13, 2015
6658273
Refactor authentication plugin
thibaultcha Feb 14, 2015
d41e9de
Fix web tests because secret_key is not required anymore
thibaultcha Feb 14, 2015
c656583
Bump busted and add tags to describes for better test granularity
thibaultcha Feb 14, 2015
741f673
Update cassandra driver and remove sqlite3
thibaultcha Feb 14, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ before_install:
- cd ..

install:
- sudo apt-get install sqlite3 libsqlite3-dev
- sudo luarocks install lrexlib-pcre PCRE_LIBDIR=$(dirname `sudo find / -type f -name "libpcre.so*" -print -quit`)
- sudo luarocks install luasec OPENSSL_LIBDIR=$(dirname `sudo find / -type f -name "libssl.so*" -print -quit`)
- sudo make global
Expand Down
82 changes: 42 additions & 40 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,79 +1,81 @@
PWD = `pwd`

# Dev environment variables
export ENV_DAEMON ?= off
export ENV_LUA_LIB ?= lua_package_path \"$(PWD)/src/?.lua\;\;\"\;
export ENV_LUA_CODE_CACHE ?= off
export ENV_APENODE_PORT ?= 8000
export ENV_APENODE_WEB_PORT ?= 8001
export ENV_DIR ?= $(PWD)/tmp
export ENV_APENODE_CONF ?= $(ENV_DIR)/apenode.dev.yaml
export ENV_SILENT ?=
export DAEMON ?= off
export LUA_LIB ?= lua_package_path \"$(PWD)/src/?.lua\;\;\"\;
export LUA_CODE_CACHE ?= on
export KONG_PORT ?= 8000
export KONG_WEB_PORT ?= 8001
export DIR ?= $(PWD)/tmp
export KONG_CONF ?= $(DIR)/kong.conf
export SILENT ?=

.PHONY: build global test test-web test-all run migrate populate drop

global:
@luarocks make apenode-*.rockspec
@luarocks make kong-*.rockspec --only-server=http://rocks.moonscript.org

test:
@busted spec/unit

test-web:
@$(MAKE) build ENV_DAEMON=on
@$(MAKE) migrate ENV_SILENT=-s
@$(MAKE) build DAEMON=on
@$(MAKE) migrate SILENT=-s
@$(MAKE) run
@$(MAKE) seed ENV_SILENT=-s
@$(MAKE) seed SILENT=-s
@busted spec/web/ || (make stop;make drop; exit 1)
@$(MAKE) stop
@$(MAKE) drop ENV_SILENT=-s
@$(MAKE) drop SILENT=-s

test-proxy:
@$(MAKE) build ENV_DAEMON=on
@$(MAKE) migrate ENV_SILENT=-s
@$(MAKE) build DAEMON=on
@$(MAKE) migrate SILENT=-s
@$(MAKE) run
@$(MAKE) seed ENV_SILENT=-s
@$(MAKE) seed SILENT=-s
@busted spec/proxy/ || (make stop;make drop; exit 1)
@$(MAKE) stop
@$(MAKE) drop ENV_SILENT=-s
@$(MAKE) drop SILENT=-s

test-all:
@$(MAKE) build ENV_DAEMON=on
@$(MAKE) migrate ENV_SILENT=-s
@$(MAKE) build DAEMON=on
@$(MAKE) migrate SILENT=-s
@$(MAKE) run
@sleep 2 # Wait for the nginx process to start
@$(MAKE) seed ENV_SILENT=-s
@$(MAKE) seed SILENT=-s
@busted spec/ || (make stop;make drop; exit 1)
@$(MAKE) stop
@$(MAKE) drop ENV_SILENT=-s
@$(MAKE) drop SILENT=-s

migrate:
@scripts/migrate migrate $(ENV_SILENT) --conf=$(ENV_APENODE_CONF)
@scripts/migrate migrate $(SILENT) --conf=$(KONG_CONF)

reset:
@scripts/migrate reset $(SILENT) --conf=$(KONG_CONF)

seed:
@scripts/seed seed $(ENV_SILENT) --conf=$(ENV_APENODE_CONF)
@scripts/seed seed $(SILENT) --conf=$(KONG_CONF)

drop:
@scripts/seed drop $(ENV_SILENT) --conf=$(ENV_APENODE_CONF)
@scripts/seed drop $(SILENT) --conf=$(KONG_CONF)

run:
@nginx -p $(ENV_DIR)/nginx -c nginx.conf
@nginx -p $(DIR)/nginx -c nginx.conf

stop:
@nginx -p $(ENV_DIR)/nginx -c nginx.conf -s stop
@nginx -p $(DIR)/nginx -c nginx.conf -s stop

build:
@mkdir -p $(ENV_DIR)/nginx/logs
@cp templates/apenode.yaml $(ENV_APENODE_CONF)
@echo "" > $(ENV_DIR)/nginx/logs/error.log
@echo "" > $(ENV_DIR)/nginx/logs/access.log
@mkdir -p $(DIR)/nginx/logs
@cp templates/kong.conf $(KONG_CONF)
@echo "" > $(DIR)/nginx/logs/error.log
@echo "" > $(DIR)/nginx/logs/access.log
@sed \
-e "s/{{DAEMON}}/$(ENV_DAEMON)/g" \
-e "s@{{LUA_LIB_PATH}}@$(ENV_LUA_LIB)@g" \
-e "s/{{LUA_CODE_CACHE}}/$(ENV_LUA_CODE_CACHE)/g" \
-e "s/{{PORT}}/$(ENV_APENODE_PORT)/g" \
-e "s/{{WEB_PORT}}/$(ENV_APENODE_WEB_PORT)/g" \
-e "s@{{APENODE_CONF}}@$(ENV_APENODE_CONF)@g" \
templates/nginx.conf > $(ENV_DIR)/nginx/nginx.conf;
-e "s/{{DAEMON}}/$(DAEMON)/g" \
-e "s@{{LUA_LIB_PATH}}@$(LUA_LIB)@g" \
-e "s/{{LUA_CODE_CACHE}}/$(LUA_CODE_CACHE)/g" \
-e "s/{{PORT}}/$(KONG_PORT)/g" \
-e "s/{{WEB_PORT}}/$(KONG_WEB_PORT)/g" \
-e "s@{{KONG_CONF}}@$(KONG_CONF)@g" \
templates/nginx.conf > $(DIR)/nginx/nginx.conf;

@cp -R src/apenode/web/static $(ENV_DIR)/nginx
@cp -R src/apenode/web/admin $(ENV_DIR)/nginx
@cp -R src/kong/web/static $(DIR)/nginx
@cp -R src/kong/web/admin $(DIR)/nginx
64 changes: 19 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Apenode
## Kong

[![Build Status](https://magnum.travis-ci.com/Mashape/lua-resty-apenode.svg?token=ZqXY1Sn8ga8gv6vUrw3N&branch=master)](https://magnum.travis-ci.com/Mashape/lua-resty-apenode)
[![Build Status](https://magnum.travis-ci.com/Mashape/kong.svg?token=ZqXY1Sn8ga8gv6vUrw3N&branch=master)](https://magnum.travis-ci.com/Mashape/kong)

```
______________________________________
Expand All @@ -17,7 +17,7 @@
- Luarocks for Lua `5.1`
- [Openrestify](http://openresty.com/#Download) `1.7.4.1`

### Run apenode (development)
### Run Kong (development)

- `make global`
- `make build`
Expand All @@ -28,19 +28,20 @@

### Commands

Commands consist of apenode's scripts and Makefile:
Commands consist of Kong's scripts and Makefile:

#### Makefile

| Name | Description |
| ------------ | --------------------------------------------------------------------------------------------------- |
| `global` | Install the apenode luarock globally |
| `build` | Generates an apenode environment (nginx + apenode configurations) in a given folder (see `ENV_DIR`) |
| `migrate` | Migrate your database according to the given apenode config (see `ENV_APENODE_CONF`) |
| `seed` | Seed your database according to the given apenode config |
| `drop` | Drop your database according to the given apenode config |
| `run` | Runs the given apenode environment in a given folder (see `ENV_DIR`) |
| `stop` | Stops the given apenode environment in a given folder (see `ENV_DIR`) |
| `global` | Install the Kong luarock globally |
| `build` | Generates a Kong environment (nginx + Kong configurations) in a given folder (see `DIR`) |
| `migrate` | Migrate your database according to the given Kong config (see `KONG_CONF`) |
| `reset` | Reset your database schema according to the given Kong config (see `KONG_CONF`) |
| `seed` | Seed your database according to the given Kong config |
| `drop` | Drop your database according to the given Kong config |
| `run` | Runs the given Kong environment in a given folder (see `DIR`) |
| `stop` | Stops the given Kong environment in a given folder (see `DIR`) |
| `test` | Runs the unit tests |
| `test-proxy` | Runs the proxy integration tests |
| `test-web` | Runs the web integration tests |
Expand All @@ -50,13 +51,13 @@ Commands consist of apenode's scripts and Makefile:

| Name | Default | Commands | Description |
| ---------------------- | ------------------------- | ------------------------- | ------------------------------------------------------------------------------ |
| `ENV_DIR` | `tmp/` | `build|run|stop` | Specify a folder where an apenode environment lives or should live if building |
| `ENV_APENODE_CONF` | `tmp/apenode.dev.yaml` | `build|migrate|seed|drop` | Points the command to the given apenode configuration file |
| `ENV_DAEMON` | `off` | `build` | Sets the nginx daemon property in the generated `nginx.conf` |
| `ENV_APENODE_PORT` | `8000` | `build` | Sets the apenode proxy port in the generated `nginx.conf` |
| `ENV_APENODE_WEB_PORT` | `8001` | `build` | Sets the apenode web port in the generated `nginx.conf` |
| `ENV_LUA_CODE_CACHE` | `off` | `build` | Sets the nginx `lua_code_cache` property in the generated `nginx.conf` |
| `ENV_LUA_LIB` | `$(PWD)/src/?.lua;;` | `build` | Sets the nginx `lua_package_path` property in the generated `nginx.conf` |
| `DIR` | `tmp/` | `build|run|stop` | Specify a folder where an Kong environment lives or should live if building |
| `KONG_CONF` | `tmp/kong.conf` | `build|migrate|seed|drop` | Points the command to the given Kong configuration file |
| `DAEMON` | `off` | `build` | Sets the nginx daemon property in the generated `nginx.conf` |
| `KONG_PORT` | `8000` | `build` | Sets Kong's proxy port in the generated `nginx.conf` |
| `KONG_WEB_PORT` | `8001` | `build` | Sets Kong's web port in the generated `nginx.conf` |
| `LUA_CODE_CACHE` | `off` | `build` | Sets the nginx `lua_code_cache` property in the generated `nginx.conf` |
| `LUA_LIB` | `$(PWD)/src/?.lua;;` | `build` | Sets the nginx `lua_package_path` property in the generated `nginx.conf` |

#### Scripts

Expand All @@ -71,30 +72,3 @@ Commands consist of apenode's scripts and Makefile:
| | `seed --conf=[conf]` | Seed the database configured in the given conf | `-s` (Optional) No output |
| | | | `-r` (Optional) Also populate random data (1000 by default) |
| | `drop --conf=[conf]` | Drop the database configured in the given conf | `-s` (Optional) No output |

### API

The Apenode provides APIs to interact with the underlying data model and create APIs, accounts and applications

#### Create APIs

`POST /apis/`

* **required** `public_dns`: The public DNS of the API
* **required** `target_url`: The target URL
* **required** `authentication_type`: The authentication to enable on the API, can be `query`, `header`, `basic`.
* **required** `authentication_key_names`: A *comma-separated* list of authentication parameter names, like `apikey` or `x-mashape-key`.

#### Create Accounts

`POST /accounts/`

* `provider_id`: A custom id to be set in the account entity

#### Create Applications

`POST /applications/`

* **required** `account_id`: The `account_id` that the application belongs to.
* `public_key`: The public key, or username if Basic Authentication is enabled.
* **required** `secret_key`: The secret key, or api key, or password if Basic authentication is enabled. Use only this fields for simple api keys.
96 changes: 0 additions & 96 deletions apenode-0.1-1.rockspec

This file was deleted.

File renamed without changes.
Loading