Skip to content

Commit 9a1a5ce

Browse files
authored
Merge pull request #428 from devicehive/development
Development
2 parents affe77b + 89b4923 commit 9a1a5ce

186 files changed

Lines changed: 5479 additions & 4428 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Jenkinsfile

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,31 @@ def deployable_branches = ["development"]
88
node('docker') {
99
stage('Build jars') {
1010
echo 'Building jars ...'
11-
def maven = docker.image('maven:3.5.0-jdk-8')
11+
def maven = docker.image('maven:3.5.2-jdk-8')
1212
maven.pull()
1313
maven.inside {
1414
checkout scm
15-
sh 'mvn clean package'
16-
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
15+
sh 'mvn clean package -DskipTests'
16+
sh 'mvn test'
17+
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
1718

18-
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'
19+
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'
1920
}
2021
}
2122

2223
stage('Build and publish Docker images in CI repository') {
23-
echo 'Building Frontend image ...'
24+
echo 'Building images ...'
2425
unstash 'jars'
2526
def auth = docker.build('devicehiveci/devicehive-auth-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-auth-rdbms.Dockerfile .')
27+
def plugin = docker.build('devicehiveci/devicehive-plugin-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-plugin-rdbms.Dockerfile .')
2628
def frontend = docker.build('devicehiveci/devicehive-frontend-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-frontend-rdbms.Dockerfile .')
2729
def backend = docker.build('devicehiveci/devicehive-backend-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-backend-rdbms.Dockerfile .')
2830
def hazelcast = docker.build('devicehiveci/devicehive-hazelcast:${BRANCH_NAME}', '-f dockerfiles/devicehive-hazelcast.Dockerfile .')
2931

32+
echo 'Pushing images to CI repository ...'
3033
docker.withRegistry('https://registry.hub.docker.com', 'devicehiveci_dockerhub'){
3134
auth.push()
35+
plugin.push()
3236
frontend.push()
3337
backend.push()
3438
hazelcast.push()
@@ -72,7 +76,7 @@ if (publishable_branches.contains(env.BRANCH_NAME)) {
7276

7377
echo("Install dependencies with npm")
7478
sh '''
75-
sudo npm install -g mocha@3.5.3 mochawesome
79+
sudo npm install -g mocha mochawesome
7680
sudo npm i
7781
'''
7882

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

9094
timeout(time:10, unit: 'MINUTES') {
9195
echo("Run integration tests")
92-
sh 'mocha -R mochawesome integration-tests'
96+
sh 'mocha --exit -R mochawesome integration-tests'
9397
}
9498
}
9599
} finally {
96-
archiveArtifacts artifacts: 'devicehive-tests/mochawesome-report/mochawesome.json, devicehive-tests/mochawesome-report/mochawesome.html', fingerprint: true, onlyIfSuccessful: true
100+
zip archive: true, dir: 'devicehive-tests', glob: 'mochawesome-report/**', zipFile: 'mochawesome-report.zip'
97101
dir('devicehive-docker/rdbms-image') {
98102
sh '''
99103
sudo docker-compose kill
@@ -117,11 +121,13 @@ if (publishable_branches.contains(env.BRANCH_NAME)) {
117121
docker tag devicehiveci/devicehive-frontend-rdbms:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-frontend-rdbms:${IMAGE_TAG}
118122
docker tag devicehiveci/devicehive-backend-rdbms:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-backend-rdbms:${IMAGE_TAG}
119123
docker tag devicehiveci/devicehive-hazelcast:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-hazelcast:${IMAGE_TAG}
124+
docker tag devicehiveci/devicehive-plugin-rdbms:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-plugin-rdbms:${IMAGE_TAG}
120125
121126
docker push registry.hub.docker.com/devicehive/devicehive-auth-rdbms:${IMAGE_TAG}
122127
docker push registry.hub.docker.com/devicehive/devicehive-frontend-rdbms:${IMAGE_TAG}
123128
docker push registry.hub.docker.com/devicehive/devicehive-backend-rdbms:${IMAGE_TAG}
124129
docker push registry.hub.docker.com/devicehive/devicehive-hazelcast:${IMAGE_TAG}
130+
docker push registry.hub.docker.com/devicehive/devicehive-plugin-rdbms:${IMAGE_TAG}
125131
"""
126132
}
127133
}
@@ -131,13 +137,14 @@ if (publishable_branches.contains(env.BRANCH_NAME)) {
131137
if (deployable_branches.contains(env.BRANCH_NAME)) {
132138
stage('Deploy build to dev server'){
133139
node('dev-server') {
134-
sh '''
135-
cd ~/devicehive-docker/rdbms-image
136-
sed -i -e "s/DH_TAG=.*/DH_TAG=${BRANCH_NAME}/g" .env
137-
sudo docker-compose pull
138-
sudo docker-compose up -d
139-
echo "$(date): Deployed build from ${BRANCH_NAME} to dev server" > ./jenkins-cd.timestamp
140-
'''
140+
dir('/home/centos/devicehive-docker/rdbms-image'){
141+
sh '''
142+
sed -i -e "s/DH_TAG=.*/DH_TAG=${BRANCH_NAME}/g" .env
143+
sudo docker-compose pull
144+
sudo docker-compose up -d
145+
echo "$(date): Deployed build from ${BRANCH_NAME} to dev server" > ./jenkins-cd.timestamp
146+
'''
147+
}
141148
}
142149
}
143150
}

devicehive-auth/pom.xml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>devicehive-server</artifactId>
77
<groupId>com.devicehive</groupId>
8-
<version>3.4.0</version>
8+
<version>3.4.1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111
<packaging>jar</packaging>
@@ -143,21 +143,5 @@
143143
</dependency>
144144
</dependencies>
145145
</profile>
146-
<profile>
147-
<id>booted-riak</id>
148-
<activation>
149-
<activeByDefault>false</activeByDefault>
150-
</activation>
151-
<properties>
152-
<finalName>devicehive-riak-${project.version}-boot</finalName>
153-
</properties>
154-
<dependencies>
155-
<dependency>
156-
<groupId>com.devicehive</groupId>
157-
<artifactId>devicehive-riak-dao</artifactId>
158-
<version>${project.parent.version}</version>
159-
</dependency>
160-
</dependencies>
161-
</profile>
162146
</profiles>
163147
</project>

devicehive-auth/src/main/java/com/devicehive/resource/AuthApiInfoResource.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
import io.swagger.annotations.ApiResponses;
2828
import org.springframework.security.access.prepost.PreAuthorize;
2929

30-
import javax.ws.rs.GET;
31-
import javax.ws.rs.Path;
32-
import javax.ws.rs.Produces;
30+
import javax.ws.rs.*;
3331
import javax.ws.rs.core.Context;
3432
import javax.ws.rs.core.Response;
3533
import javax.ws.rs.core.UriInfo;
@@ -48,6 +46,9 @@ public interface AuthApiInfoResource {
4846
message = "Returns version of API, server timestamp and WebSocket base uri",
4947
response = ApiInfoVO.class),
5048
})
51-
Response getApiInfo(@Context UriInfo uriInfo);
49+
Response getApiInfo(@Context UriInfo uriInfo,
50+
@HeaderParam("X-DH-wss-enabled")
51+
@DefaultValue("false")
52+
Boolean wssEnabled);
5253

5354
}

devicehive-auth/src/main/java/com/devicehive/resource/JwtTokenResource.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
* #L%
2121
*/
2222

23-
import com.devicehive.security.jwt.JwtPayloadView;
23+
import com.devicehive.security.jwt.JwtUserPayloadView;
24+
import com.devicehive.security.jwt.JwtPluginPayload;
2425
import com.devicehive.vo.JwtAccessTokenVO;
2526
import com.devicehive.vo.JwtRefreshTokenVO;
2627
import com.devicehive.vo.JwtRequestVO;
@@ -35,9 +36,12 @@
3536
import org.springframework.security.access.prepost.PreAuthorize;
3637

3738
import javax.ws.rs.Consumes;
39+
import javax.ws.rs.GET;
40+
import javax.ws.rs.HeaderParam;
3841
import javax.ws.rs.POST;
3942
import javax.ws.rs.Path;
4043
import javax.ws.rs.Produces;
44+
import javax.ws.rs.QueryParam;
4145
import javax.ws.rs.core.MediaType;
4246
import javax.ws.rs.core.Response;
4347

@@ -68,7 +72,25 @@ public interface JwtTokenResource {
6872
})
6973
Response tokenRequest(
7074
@ApiParam(name = "payload", value = "Payload", required = true)
71-
JwtPayloadView payloadView);
75+
JwtUserPayloadView payloadView);
76+
77+
@POST
78+
@Path("/plugin/create")
79+
@Consumes(APPLICATION_JSON)
80+
@PreAuthorize("isAuthenticated() and hasPermission(null, 'MANAGE_PLUGIN')")
81+
@ApiOperation(value = "JWT access and refresh token request for plugin")
82+
@ApiImplicitParams({
83+
@ApiImplicitParam(name = "Authorization", value = "Authorization token", required = true, dataType = "string", paramType = "header")
84+
})
85+
@ApiResponses({
86+
@ApiResponse(code = 201,
87+
message = "If successful, this method returns a JWT access and refresh token in the response body.",
88+
response = JwtTokenVO.class),
89+
@ApiResponse(code = 404, message = "If access token not found")
90+
})
91+
Response pluginTokenRequest(
92+
@ApiParam(name = "payload", value = "Payload", required = true)
93+
JwtPluginPayload payload);
7294

7395
@POST
7496
@Path("/refresh")
@@ -97,5 +119,19 @@ Response refreshTokenRequest(
97119
Response login(
98120
@ApiParam(value = "Access key request", required = true)
99121
JwtRequestVO request);
122+
123+
@GET
124+
@Path("/plugin/authenticate")
125+
@PreAuthorize("permitAll")
126+
@ApiOperation(value = "Plugin authentication", notes = "Authenticates a plugin and JWT Plugin payload.")
127+
@ApiResponses(value = {
128+
@ApiResponse(code = 200, message = "If successful, this method returns the JwtPluginPayload.",
129+
response = JwtPluginPayload.class),
130+
@ApiResponse(code = 401, message = "If authentication is not allowed")
131+
})
132+
Response authenticatePlugin(
133+
@ApiParam(name = "token", value = "Jwt Plugin Token", required = true)
134+
@QueryParam("token")
135+
String jwtPluginToken);
100136
}
101137

devicehive-auth/src/main/java/com/devicehive/resource/impl/AuthApiInfoResourceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public AuthApiInfoResourceImpl(BaseApiInfoResource baseApiInfoResource) {
4040
}
4141

4242
@Override
43-
public Response getApiInfo(UriInfo uriInfo) {
44-
return baseApiInfoResource.getApiInfo(uriInfo);
43+
public Response getApiInfo(UriInfo uriInfo, Boolean wssEnabled) {
44+
return baseApiInfoResource.getApiInfo(uriInfo, wssEnabled);
4545
}
4646
}

0 commit comments

Comments
 (0)