Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #60 from thehyve/rc.1.0.0
Browse files Browse the repository at this point in the history
rc.1.0.0
  • Loading branch information
ewelinagr authored Jan 8, 2018
2 parents 1c11e4b + 1bf0c52 commit e30ef5d
Show file tree
Hide file tree
Showing 123 changed files with 4,043 additions and 782 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ gradle/wrapper
out

# IDEs and editors
/.idea
.idea
*/.idea
*.iml
/lib
.project
Expand Down
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ cache:
- $HOME/.m2

before_install:
- sudo apt-get -qq update
- sudo apt-get install -y html2text
- pushd data-showcase
- gradle wrapper
- GRADLE_SCRIPT="$(pwd)/gradlew"
Expand All @@ -33,6 +35,11 @@ script:
- ${GRADLE_SCRIPT} test
- popd

after_failure:
- echo "Writing reports..."
- html2text data-showcase/build/reports/tests/test/index.html
- for f in data-showcase/build/reports/tests/test/classes/*.html; do echo "$f"; html2text "$f"; done

notifications:
webhooks:
on_success: change
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ gradle wrapper
cd src/main/user-interface
npm start

# Package, creates build/lib/data-showcase-0.0.1-SNAPSHOT.war
# Package, creates build/lib/data-showcase-1.0.0.war
./gradlew assemble

# Run the war
java -jar build/libs/data-showcase-0.0.1-SNAPSHOT.war
java -jar build/libs/data-showcase-1.0.0.war
```

## Publish
Expand All @@ -55,7 +55,7 @@ Publish to Nexus:
# Deploy to the Nexus repository https://repo.thehyve.nl
./gradlew publish
```
This publishes the artifact `nl.thehyve:data-showcase:0.0.1-SNAPSHOT:war`.
This publishes the artifact `nl.thehyve:data-showcase:1.0.0:war`.

## Deploy
For deployment, fetch the application war file from the Nexus repository,
Expand All @@ -64,7 +64,7 @@ and run the application with an external config file:
MEMORY_OPTIONS="-Xms2g -Xmx2g -XX:MaxPermSize=512m"
JAVA_OPTIONS="-server -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
APP_OPTIONS="-Dgrails.env=prod -Dspring.config.location=/home/user/data-showcase-internal.yml"
java -jar ${JAVA_OPTIONS} ${MEMORY_OPTIONS} ${APP_OPTIONS} data-showcase-0.0.1-SNAPHOT.war
java -jar ${JAVA_OPTIONS} ${MEMORY_OPTIONS} ${APP_OPTIONS} data-showcase-1.0.0.war
```

Example configuration file `data-showcase-internal.yml`:
Expand Down
1 change: 1 addition & 0 deletions data-showcase-api-e2e/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {

testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
testCompile 'io.github.http-builder-ng:http-builder-ng-apache:0.17.0'
testCompile 'io.github.http-builder-ng:http-builder-ng-okhttp:0.17.0'
}

tasks.withType(Test) { systemProperties = System.getProperties() }
Expand Down
5 changes: 5 additions & 0 deletions data-showcase-api-e2e/src/test/groovy/base/RestHelper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package base

import groovyx.net.http.FromServer
import groovyx.net.http.HttpBuilder
import groovyx.net.http.OkHttpEncoders

import static config.Config.AUTH_NEEDED
import static config.Config.DEFAULT_USER
Expand Down Expand Up @@ -81,6 +82,10 @@ class RestHelper {
request.contentType = requestMap.contentType ?: ContentTypeFor.JSON
request.body = requestMap.body

if(requestMap.contentType == 'multipart/form-data') {
request.encoder 'multipart/form-data', OkHttpEncoders.&multipart
}

if (!requestMap.skipOauth && AUTH_NEEDED) {
testContext.getAuthAdapter().authenticate(getRequest(), (requestMap.user ?: DEFAULT_USER))
}
Expand Down
2 changes: 2 additions & 0 deletions data-showcase-api-e2e/src/test/groovy/config/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ class Config {
//settings
public static final boolean AUTH_NEEDED = false
public static final String DEFAULT_USER = 'default'
public static final String TOKEN = 'TestToken123!'

}
115 changes: 107 additions & 8 deletions data-showcase-api-e2e/src/test/groovy/tests/rest/DataImportSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,36 @@
package tests.rest

import base.RESTSpec
import static config.Config.TOKEN
import static groovyx.net.http.MultipartContent.multipart

class DataImportSpec extends RESTSpec {

def "upload valid data"() {
given:
def env = get([path: '/api/environment'])
assert env['grailsEnvironment'] == 'test'
assert env['environment'] == 'Public'
get([path: '/api/test/clearDatabase'])

when:
def file = new File(getClass().getResource("/test.json").toURI())
def requestToken = TOKEN
def request = [
path : '/api/data_import/upload',
contentType: 'multipart/form-data',
body : multipart {
field 'requestToken', requestToken
part 'file', 'test.json', 'text/plain', file
},
statusCode : 200
]
def response = post(request)

then:
assert response.message == "Data successfully uploaded"
}

def "upload data with invalid requestToken"() {
given:
def env = get([path: '/api/environment'])
Expand All @@ -19,19 +46,91 @@ class DataImportSpec extends RESTSpec {
get([path: '/api/test/clearDatabase'])

when:
def file = null
//file = new GrailsMockMultipartFile('testFile', 'test file contents'.bytes)
def requestToken = ""
def file = new File(getClass().getResource("/test.json").toURI())
def request = [
path: '/api/data_import/upload',
body: toJSON([
file : file,
requestToken: null
]),
statusCode: 401
path : '/api/data_import/upload',
contentType: 'multipart/form-data',
body : multipart {
field 'requestToken', requestToken
part 'file', 'test.json', 'text/plain', file
},
statusCode : 401
]
def response = post(request)

then:
assert response.error == 'requestToken is required to upload the data'

when:
requestToken = "invalid"
request = [
path : '/api/data_import/upload',
contentType: 'multipart/form-data',
body : multipart {
field 'requestToken', requestToken
part 'file', 'test.json', 'text/plain', file
},
statusCode : 401
]
response = post(request)

then:
assert response.error == "requestToken: $requestToken is invalid"
}

def "upload invalid data"() {
given:
def env = get([path: '/api/environment'])
assert env['grailsEnvironment'] == 'test'
assert env['environment'] == 'Public'
get([path: '/api/test/clearDatabase'])

when:
// File with invalid data:
// project names not unique, concept code of the first item is missing
def file = new File(getClass().getResource("/test_invalid.json").toURI())
def requestToken = TOKEN
def request = [
path : '/api/data_import/upload',
contentType: 'multipart/form-data',
body : multipart {
field 'requestToken', requestToken
part 'file', 'test.json', 'text/plain', file
},
statusCode : 400
]
def response = post(request)

then:
assert response.status == 400
assert response.error == "Bad Request"
}

def "upload empty file"() {
given:
def env = get([path: '/api/environment'])
assert env['grailsEnvironment'] == 'test'
assert env['environment'] == 'Public'
get([path: '/api/test/clearDatabase'])

when:
def file = new File(getClass().getResource("/test_invalid.json").toURI())
def requestToken = TOKEN
def request = [
path : '/api/data_import/upload',
contentType: 'multipart/form-data',
body : multipart {
field 'requestToken', requestToken
part 'file', 'test.json', 'text/plain', file
},
statusCode : 400
]
def response = post(request)

then:
assert response.status == 400
assert response.error == "Bad Request"
}

}
Loading

0 comments on commit e30ef5d

Please sign in to comment.