Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
outofcoffee committed Apr 23, 2016
2 parents bd69f7a + 9478c60 commit 0db10bb
Show file tree
Hide file tree
Showing 40 changed files with 710 additions and 98 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jdk:
services:
- docker
before_install:
- docker pull apiman/on-wildfly8:1.2.1.Final
- docker pull apiman/on-wildfly10:1.2.4.Final
script:
- docker run -d -p 8080:8080 apiman/on-wildfly8:1.2.1.Final
- docker run -d -p 8080:8080 apiman/on-wildfly10:1.2.4.Final
- ./gradlew test -PintegrationTest --info
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
## [0.2.0] - 2016-04-23
### Added
- ...
- Adds support for shared properties within declaration files, which can be reused throughout the file.
- Adds support for APIs with HTTP Basic Authorization.
- Updates versions of various dependencies.

## [0.1.9]
## [0.1.9] - 2016-03-01
### Added
- Adds support for shared policy definitions, allowing you to define a policy configuration once and reuse it in multiple APIs.
- Adds shared policy examples.
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Add a plugin:
$ ./apiman plugin add \
--groupId io.apiman.plugins \
--artifactId apiman-plugins-test-policy \
--version 1.2.1.Final
--version 1.2.4.Final

You can do much more - see the [Usage](#usage) section.

Expand Down Expand Up @@ -110,6 +110,17 @@ You can also use placeholders in your declaration files. This helps you reuse de

./apiman apply -f simple.yml -P myApiEndpoint=http://example.com

## Shared policies and properties

To avoid repeating the same policy definitions, you can define them once in the _shared_ section of your declaration file,
then refer to them by name later.

For example, see the [shared-policies.yml](shared-policies.yml) file.

The same goes for properties - you can define them in the _shared_ section and reuse them.

See the [shared-properties.yml](shared-properties.yml) example file.

# Requirements

* An instance of [apiman](http://apiman.io)
Expand Down
63 changes: 43 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@
*/

group 'io.apiman.cli'
version '0.1.9'
version '0.2.0'

buildscript {
repositories { jcenter() }
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.2'
classpath "com.github.jengelman.gradle.plugins:shadow:1.2.3"
}
}

apply plugin: 'java'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: "com.github.johnrengelman.shadow"

repositories {
mavenCentral()
Expand All @@ -35,23 +40,42 @@ compileJava {
sourceCompatibility = '1.8'
}

ext {
version_args4j = '2.33'
version_log4j = '2.5'
version_guava = '19.0'
version_retrofit = '1.9.0'
version_jackson = '1.9.0'
version_jackson_yaml = '2.7.3'
version_modelmapper = '0.7.5'
version_commons_lang = '3.4'
version_guice = '4.0'

// test dependencies
version_junit = '4.12'
version_ducttape = '1.0.5'
version_mockito = '1.10.19'
version_restassured = '2.9.0'
}

dependencies {
compile 'args4j:args4j:2.32'
compile 'org.apache.logging.log4j:log4j-core:2.5'
compile 'com.google.guava:guava:19.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.retrofit:converter-jackson:1.9.0'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.5.4'
compile 'org.modelmapper:modelmapper:0.7.5'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.google.inject:guice:4.0'
compile "args4j:args4j:$version_args4j"
compile "org.apache.logging.log4j:log4j-core:$version_log4j"
compile "com.google.guava:guava:$version_guava"
compile "com.squareup.retrofit:retrofit:$version_retrofit"
compile "com.squareup.retrofit:converter-jackson:$version_retrofit"
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$version_jackson_yaml"
compile "org.modelmapper:modelmapper:$version_modelmapper"
compile "org.apache.commons:commons-lang3:$version_commons_lang"
compile "com.google.inject:guice:$version_guice"

// route slf4j events to log4j2
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
compile "org.apache.logging.log4j:log4j-slf4j-impl:$version_log4j"

testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'org.rnorth.duct-tape:duct-tape:1.0.4'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile "junit:junit:$version_junit"
testCompile "org.rnorth.duct-tape:duct-tape:$version_ducttape"
testCompile "org.mockito:mockito-core:$version_mockito"
testCompile "com.jayway.restassured:rest-assured:$version_restassured"
}

jar {
Expand All @@ -68,9 +92,8 @@ shadowJar {

test {
useJUnit {
if (project.hasProperty('integrationTest')) {
includeCategories 'io.apiman.cli.common.IntegrationTest'
} else {
// exclude integration tests unless explicitly included
if (!project.hasProperty('integrationTest')) {
excludeCategories 'io.apiman.cli.common.IntegrationTest'
}
}
Expand Down
54 changes: 54 additions & 0 deletions examples/declarative/backend-requires-http-auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"system": {
"gateways": [
{
"name": "test-gw",
"description": "Test Gateway",
"type": "REST",
"config": {
"endpoint": "http://localhost:8080/apiman-gateway-api",
"username": "apimanager",
"password": "apiman123!"
}
}
],
"plugins": [
{
"groupId": "io.apiman.plugins",
"artifactId": "apiman-plugins-test-policy",
"version": "1.2.1.Final"
}
]
},
"org": {
"name": "test",
"description": "Test organisation",
"apis": [
{
"name": "example",
"description": "Example API",
"initialVersion": "1.0",
"published": true,
"config": {
"endpoint": "http://example.com",
"endpointType": "rest",
"public": true,
"gateway": "test-gw",
"security": {
"authorizationType": "basic",
"username": "user",
"password": "Password123"
}
},
"policies": [
{
"name": "CachingPolicy",
"config": {
"ttl": 60
}
}
]
}
]
}
}
36 changes: 36 additions & 0 deletions examples/declarative/backend-requires-http-auth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Simple apiman example
---
system:
gateways:
- name: "test-gw"
description: "Test Gateway"
type: "REST"
config:
endpoint: "http://localhost:8080/apiman-gateway-api"
username: "apimanager"
password: "apiman123!"
plugins:
- groupId: "io.apiman.plugins"
artifactId: "apiman-plugins-test-policy"
version: "1.2.1.Final"
org:
name: "test"
description: "Test organisation"
apis:
- name: "example"
description: "Example API"
initialVersion: "1.0"
published: true
config:
endpoint: "http://example.com"
endpointType: "rest"
security:
authorizationType: "basic"
username: "user"
password: "Password123"
public: true
gateway: "test-gw"
policies:
- name: "CachingPolicy"
config:
ttl: 60
2 changes: 1 addition & 1 deletion examples/declarative/shared-policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
"groupId": "io.apiman.plugins",
"artifactId": "apiman-plugins-test-policy",
"version": "1.2.1.Final"
"version": "1.2.4.Final"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion examples/declarative/shared-policies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
plugins:
- groupId: "io.apiman.plugins"
artifactId: "apiman-plugins-test-policy"
version: "1.2.1.Final"
version: "1.2.4.Final"
shared:
policies:
- $id: "sharedPolicy"
Expand Down
36 changes: 36 additions & 0 deletions examples/declarative/shared-properties.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Shared properties example
---
system:
gateways:
- name: "test-gw"
description: "Test Gateway"
type: "REST"
config:
endpoint: "http://localhost:8080/apiman-gateway-api"
username: "apimanager"
password: "apiman123!"
shared:
properties:
commonApiEndpoint: "http://example.com"
org:
name: "test"
description: "Test organisation"
apis:
- name: "example1"
description: "Example API 1"
initialVersion: "1.0"
published: true
config:
endpoint: "${commonApiEndpoint}"
endpointType: "rest"
public: true
gateway: "test-gw"
- name: "example2"
description: "Example API 2"
initialVersion: "1.0"
published: true
config:
endpoint: "${commonApiEndpoint}"
endpointType: "rest"
public: true
gateway: "test-gw"
2 changes: 1 addition & 1 deletion examples/declarative/simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
"groupId": "io.apiman.plugins",
"artifactId": "apiman-plugins-test-policy",
"version": "1.2.1.Final"
"version": "1.2.4.Final"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion examples/declarative/simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
plugins:
- groupId: "io.apiman.plugins"
artifactId: "apiman-plugins-test-policy"
version: "1.2.1.Final"
version: "1.2.4.Final"
org:
name: "test"
description: "Test organisation"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
22 changes: 16 additions & 6 deletions src/main/java/io/apiman/cli/command/AbstractCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import io.apiman.cli.core.common.model.ManagementApiVersion;
import io.apiman.cli.exception.CommandException;
import io.apiman.cli.exception.ExitWithCodeException;
import io.apiman.cli.util.LogUtil;
import io.apiman.cli.management.ManagementApiUtil;
import io.apiman.cli.util.LogUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kohsuke.args4j.CmdLineException;
Expand All @@ -31,6 +31,8 @@
import java.util.List;
import java.util.Map;

import static io.apiman.cli.util.AuthUtil.DEFAULT_SERVER_PASSWORD;
import static io.apiman.cli.util.AuthUtil.DEFAULT_SERVER_USERNAME;
import static io.apiman.cli.util.LogUtil.LINE_SEPARATOR;

/**
Expand All @@ -39,8 +41,6 @@
public abstract class AbstractCommand implements Command {
private static final Logger LOGGER = LogManager.getLogger(AbstractCommand.class);
private static final String DEFAULT_SERVER_ADDRESS = "http://localhost:8080/apiman";
private static final String DEFAULT_SERVER_USERNAME = "admin";
private static final String DEFAULT_SERVER_PASSWORD = "admin123!";

/**
* Maps commands (e.g. 'org' or 'create') to their implementations.
Expand All @@ -66,6 +66,10 @@ public abstract class AbstractCommand implements Command {
* The parent Command (<code>null</code> if root).
*/
private Command parent;

/**
* The name of this command.
*/
private String commandName;

public AbstractCommand() {
Expand All @@ -91,10 +95,16 @@ public void setParent(Command parent) {
this.parent = parent;
}

/**
* @param commandName the name of this command
*/
public void setCommandName(String commandName) {
this.commandName = commandName;
}

/**
* @return the name of this command
*/
public String getCommandName() {
return commandName;
}
Expand Down Expand Up @@ -287,17 +297,17 @@ protected <T> T buildServerApiClient(Class<T> clazz, ManagementApiVersion server
}

protected String getManagementApiEndpoint() {
// TODO read from config/environment
// TODO consider reading from config file/environment
return serverAddress;
}

private String getManagementApiUsername() {
// TODO read from config/environment
// TODO consider reading from config file/environment
return serverUsername;
}

private String getManagementApiPassword() {
// TODO read from config/environment
// TODO consider reading from config file/environment
return serverPassword;
}

Expand Down
Loading

0 comments on commit 0db10bb

Please sign in to comment.