Commit 703d6579 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub

add spotless for license header (#3)

parent 1259e97b
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
\ No newline at end of file
......@@ -11,13 +11,11 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // Required for Kotlin integration
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version" // See https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-spring-compiler-plugin
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_version"
classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.0"
classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.0"
}
}
plugins {
id 'com.bonitasoft.gradle.bonita-base-plugin' version '0.1.15'
}
plugins { id 'com.bonitasoft.gradle.bonita-base-plugin' version '0.1.15' }
apply plugin: "kotlin" // Required for Kotlin integration
apply plugin: "kotlin-spring" // See https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-spring-compiler-plugin
......@@ -28,31 +26,33 @@ apply plugin: 'maven-publish'
group = 'org.bonitasoft.releng'
junitPlatform {
filters {
engines {
include 'spek'
}
}
filters {
engines { include 'spek' }
}
}
repositories {
jcenter()
maven { url 'http://repositories.rd.lan/maven/all/' }
maven {
url 'http://repository.jetbrains.com/all'
}
maven { url 'http://repository.jetbrains.com/all' }
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.springframework.boot:spring-boot-starter-web:$spring_boot_version"
compile "org.springframework.boot:spring-boot-starter-test:$spring_boot_version"
testCompile 'org.jetbrains.spek:spek-api:1.1.5'
testCompile 'org.jetbrains.spek:spek-junit-platform-engine:1.1.5'
testCompile 'org.junit.platform:junit-platform-runner:1.0.0'
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testCompile 'org.jetbrains.spek:spek-junit-platform-engine:1.1.5'
testCompile 'org.junit.platform:junit-platform-runner:1.0.0'
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}
spotless {
kotlin {
licenseHeaderFile rootProject.file('LICENSE')
}
}
scmVersion {
......@@ -73,11 +73,9 @@ publishing {
}
}
}
publications {
bootJava(MavenPublication) {
artifact bootJar
}
bootJava(MavenPublication) { artifact bootJar }
}
}
......
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.releng
import org.springframework.boot.SpringApplication
......@@ -6,6 +20,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
@SpringBootApplication
class CodeSignApp
fun main(args : Array<String>) {
fun main(args: Array<String>) {
SpringApplication.run(CodeSignApp::class.java, *args)
}
\ No newline at end of file
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.releng
import org.apache.commons.logging.Log
......@@ -23,11 +37,12 @@ class CodeSigningRestController {
logger.error("File '%s' is empty".format(file.originalFilename))
response.setStatus(400)
return StreamingResponseBody { outputStream ->
outputStream.write("File '%s' is empty".format(file.originalFilename).toByteArray()) }
outputStream.write("File '%s' is empty".format(file.originalFilename).toByteArray())
}
}
try {
val directory = Files.createTempDirectory("codeSign")
val directory = Files.createTempDirectory("codeSign")
val exeCopy = directory.resolve(file.originalFilename)
logger.info("Copy of input file into $directory...")
file.getInputStream().use { inputStream ->
......@@ -46,10 +61,11 @@ class CodeSigningRestController {
logger.error("An error occured while signing file.")
response.setStatus(500);
return StreamingResponseBody { outputStream ->
outputStream.write("An error occured while signing file.".toByteArray()) }
outputStream.write("An error occured while signing file.".toByteArray())
}
}
return StreamingResponseBody { outputStream ->
return StreamingResponseBody { outputStream ->
FileInputStream(exeCopy.toFile().canonicalFile).use { inputStream ->
inputStream.copyTo(outputStream)
directory.toFile().deleteRecursively()
......@@ -57,9 +73,10 @@ class CodeSigningRestController {
}
} catch (e: Throwable) {
logger.error("An error occured", e);
}
}
return StreamingResponseBody { outputStream ->
outputStream.write("An error occured server side. Check logs.".toByteArray()) }
outputStream.write("An error occured server side. Check logs.".toByteArray())
}
}
}
\ No newline at end of file
/**
* Copyright (C) 2018 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.releng
import org.jetbrains.spek.api.Spek
......@@ -14,20 +28,20 @@ import kotlin.test.assertEquals
@RunWith(JUnitPlatform::class)
class CodeSigningRestControllerTest : Spek({
given("a controller and an empty file") {
val controller: CodeSigningRestController = CodeSigningRestController()
val response = MockHttpServletResponse()
given("a controller and an empty file") {
val controller: CodeSigningRestController = CodeSigningRestController()
val response = MockHttpServletResponse()
val file: MultipartFile = Mockito.mock(MultipartFile::class.java)
Mockito.`when`(file.isEmpty).thenReturn(true)
Mockito.`when`(file.originalFilename).thenReturn("fileName")
val file: MultipartFile = Mockito.mock(MultipartFile::class.java)
Mockito.`when`(file.isEmpty).thenReturn(true)
Mockito.`when`(file.originalFilename).thenReturn("fileName")
on("sending file to controller") {
controller.singleFileUpload(file, response)
on("sending file to controller") {
controller.singleFileUpload(file, response)
it("should set a code 400 on the response") {
assertEquals(response.status, 400)
}
}
}
it("should set a code 400 on the response") {
assertEquals(response.status, 400)
}
}
}
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment