Skip to content

Commit

Permalink
Merge pull request #428 from devicehive/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
tmatvienko authored Nov 21, 2017
2 parents affe77b + 89b4923 commit 9a1a5ce
Show file tree
Hide file tree
Showing 186 changed files with 5,479 additions and 4,428 deletions.
37 changes: 22 additions & 15 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,31 @@ def deployable_branches = ["development"]
node('docker') {
stage('Build jars') {
echo 'Building jars ...'
def maven = docker.image('maven:3.5.0-jdk-8')
def maven = docker.image('maven:3.5.2-jdk-8')
maven.pull()
maven.inside {
checkout scm
sh 'mvn clean package'
archiveArtifacts artifacts: 'devicehive-backend/target/devicehive-backend-*-boot.jar, devicehive-auth/target/devicehive-auth-*-boot.jar, devicehive-frontend/target/devicehive-frontend-*-boot.jar, devicehive-common/target/devicehive-common-*-shade.jar', fingerprint: true, onlyIfSuccessful: true
sh 'mvn clean package -DskipTests'
sh 'mvn test'
archiveArtifacts artifacts: 'devicehive-backend/target/devicehive-backend-*-boot.jar, devicehive-auth/target/devicehive-auth-*-boot.jar, devicehive-plugin/target/devicehive-plugin-*-boot.jar, devicehive-frontend/target/devicehive-frontend-*-boot.jar, devicehive-common/target/devicehive-common-*-shade.jar', fingerprint: true, onlyIfSuccessful: true

stash includes:'devicehive-backend/target/devicehive-backend-*-boot.jar, devicehive-auth/target/devicehive-auth-*-boot.jar, devicehive-frontend/target/devicehive-frontend-*-boot.jar, devicehive-common/target/devicehive-common-*-shade.jar', name: 'jars'
stash includes:'devicehive-backend/target/devicehive-backend-*-boot.jar, devicehive-auth/target/devicehive-auth-*-boot.jar, devicehive-plugin/target/devicehive-plugin-*-boot.jar, devicehive-frontend/target/devicehive-frontend-*-boot.jar, devicehive-common/target/devicehive-common-*-shade.jar', name: 'jars'
}
}

stage('Build and publish Docker images in CI repository') {
echo 'Building Frontend image ...'
echo 'Building images ...'
unstash 'jars'
def auth = docker.build('devicehiveci/devicehive-auth-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-auth-rdbms.Dockerfile .')
def plugin = docker.build('devicehiveci/devicehive-plugin-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-plugin-rdbms.Dockerfile .')
def frontend = docker.build('devicehiveci/devicehive-frontend-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-frontend-rdbms.Dockerfile .')
def backend = docker.build('devicehiveci/devicehive-backend-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-backend-rdbms.Dockerfile .')
def hazelcast = docker.build('devicehiveci/devicehive-hazelcast:${BRANCH_NAME}', '-f dockerfiles/devicehive-hazelcast.Dockerfile .')

echo 'Pushing images to CI repository ...'
docker.withRegistry('https://registry.hub.docker.com', 'devicehiveci_dockerhub'){
auth.push()
plugin.push()
frontend.push()
backend.push()
hazelcast.push()
Expand Down Expand Up @@ -72,7 +76,7 @@ if (publishable_branches.contains(env.BRANCH_NAME)) {

echo("Install dependencies with npm")
sh '''
sudo npm install -g mocha@3.5.3 mochawesome
sudo npm install -g mocha mochawesome
sudo npm i
'''

Expand All @@ -89,11 +93,11 @@ if (publishable_branches.contains(env.BRANCH_NAME)) {

timeout(time:10, unit: 'MINUTES') {
echo("Run integration tests")
sh 'mocha -R mochawesome integration-tests'
sh 'mocha --exit -R mochawesome integration-tests'
}
}
} finally {
archiveArtifacts artifacts: 'devicehive-tests/mochawesome-report/mochawesome.json, devicehive-tests/mochawesome-report/mochawesome.html', fingerprint: true, onlyIfSuccessful: true
zip archive: true, dir: 'devicehive-tests', glob: 'mochawesome-report/**', zipFile: 'mochawesome-report.zip'
dir('devicehive-docker/rdbms-image') {
sh '''
sudo docker-compose kill
Expand All @@ -117,11 +121,13 @@ if (publishable_branches.contains(env.BRANCH_NAME)) {
docker tag devicehiveci/devicehive-frontend-rdbms:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-frontend-rdbms:${IMAGE_TAG}
docker tag devicehiveci/devicehive-backend-rdbms:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-backend-rdbms:${IMAGE_TAG}
docker tag devicehiveci/devicehive-hazelcast:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-hazelcast:${IMAGE_TAG}
docker tag devicehiveci/devicehive-plugin-rdbms:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-plugin-rdbms:${IMAGE_TAG}
docker push registry.hub.docker.com/devicehive/devicehive-auth-rdbms:${IMAGE_TAG}
docker push registry.hub.docker.com/devicehive/devicehive-frontend-rdbms:${IMAGE_TAG}
docker push registry.hub.docker.com/devicehive/devicehive-backend-rdbms:${IMAGE_TAG}
docker push registry.hub.docker.com/devicehive/devicehive-hazelcast:${IMAGE_TAG}
docker push registry.hub.docker.com/devicehive/devicehive-plugin-rdbms:${IMAGE_TAG}
"""
}
}
Expand All @@ -131,13 +137,14 @@ if (publishable_branches.contains(env.BRANCH_NAME)) {
if (deployable_branches.contains(env.BRANCH_NAME)) {
stage('Deploy build to dev server'){
node('dev-server') {
sh '''
cd ~/devicehive-docker/rdbms-image
sed -i -e "s/DH_TAG=.*/DH_TAG=${BRANCH_NAME}/g" .env
sudo docker-compose pull
sudo docker-compose up -d
echo "$(date): Deployed build from ${BRANCH_NAME} to dev server" > ./jenkins-cd.timestamp
'''
dir('/home/centos/devicehive-docker/rdbms-image'){
sh '''
sed -i -e "s/DH_TAG=.*/DH_TAG=${BRANCH_NAME}/g" .env
sudo docker-compose pull
sudo docker-compose up -d
echo "$(date): Deployed build from ${BRANCH_NAME} to dev server" > ./jenkins-cd.timestamp
'''
}
}
}
}
18 changes: 1 addition & 17 deletions devicehive-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>devicehive-server</artifactId>
<groupId>com.devicehive</groupId>
<version>3.4.0</version>
<version>3.4.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
Expand Down Expand Up @@ -143,21 +143,5 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>booted-riak</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<finalName>devicehive-riak-${project.version}-boot</finalName>
</properties>
<dependencies>
<dependency>
<groupId>com.devicehive</groupId>
<artifactId>devicehive-riak-dao</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
import io.swagger.annotations.ApiResponses;
import org.springframework.security.access.prepost.PreAuthorize;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
Expand All @@ -48,6 +46,9 @@ public interface AuthApiInfoResource {
message = "Returns version of API, server timestamp and WebSocket base uri",
response = ApiInfoVO.class),
})
Response getApiInfo(@Context UriInfo uriInfo);
Response getApiInfo(@Context UriInfo uriInfo,
@HeaderParam("X-DH-wss-enabled")
@DefaultValue("false")
Boolean wssEnabled);

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* #L%
*/

import com.devicehive.security.jwt.JwtPayloadView;
import com.devicehive.security.jwt.JwtUserPayloadView;
import com.devicehive.security.jwt.JwtPluginPayload;
import com.devicehive.vo.JwtAccessTokenVO;
import com.devicehive.vo.JwtRefreshTokenVO;
import com.devicehive.vo.JwtRequestVO;
Expand All @@ -35,9 +36,12 @@
import org.springframework.security.access.prepost.PreAuthorize;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

Expand Down Expand Up @@ -68,7 +72,25 @@ public interface JwtTokenResource {
})
Response tokenRequest(
@ApiParam(name = "payload", value = "Payload", required = true)
JwtPayloadView payloadView);
JwtUserPayloadView payloadView);

@POST
@Path("/plugin/create")
@Consumes(APPLICATION_JSON)
@PreAuthorize("isAuthenticated() and hasPermission(null, 'MANAGE_PLUGIN')")
@ApiOperation(value = "JWT access and refresh token request for plugin")
@ApiImplicitParams({
@ApiImplicitParam(name = "Authorization", value = "Authorization token", required = true, dataType = "string", paramType = "header")
})
@ApiResponses({
@ApiResponse(code = 201,
message = "If successful, this method returns a JWT access and refresh token in the response body.",
response = JwtTokenVO.class),
@ApiResponse(code = 404, message = "If access token not found")
})
Response pluginTokenRequest(
@ApiParam(name = "payload", value = "Payload", required = true)
JwtPluginPayload payload);

@POST
@Path("/refresh")
Expand Down Expand Up @@ -97,5 +119,19 @@ Response refreshTokenRequest(
Response login(
@ApiParam(value = "Access key request", required = true)
JwtRequestVO request);

@GET
@Path("/plugin/authenticate")
@PreAuthorize("permitAll")
@ApiOperation(value = "Plugin authentication", notes = "Authenticates a plugin and JWT Plugin payload.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "If successful, this method returns the JwtPluginPayload.",
response = JwtPluginPayload.class),
@ApiResponse(code = 401, message = "If authentication is not allowed")
})
Response authenticatePlugin(
@ApiParam(name = "token", value = "Jwt Plugin Token", required = true)
@QueryParam("token")
String jwtPluginToken);
}

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public AuthApiInfoResourceImpl(BaseApiInfoResource baseApiInfoResource) {
}

@Override
public Response getApiInfo(UriInfo uriInfo) {
return baseApiInfoResource.getApiInfo(uriInfo);
public Response getApiInfo(UriInfo uriInfo, Boolean wssEnabled) {
return baseApiInfoResource.getApiInfo(uriInfo, wssEnabled);
}
}
Loading

0 comments on commit 9a1a5ce

Please sign in to comment.