Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/hndrs-gradle-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ jobs:
check:
runs-on: ubuntu-latest

services:
mongodb:
image: mongo
ports:
- 27017:27017
steps:
- name: git checkout
uses: actions/checkout@v2
Expand All @@ -33,5 +38,10 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: test
env:
ARTIFACTS_AUTH0_DOMAIN: ${{ secrets.ARTIFACTS_AUTH0_DOMAIN }}
ARTIFACTS_AUTH0_CLIENTID: ${{ secrets.ARTIFACTS_AUTH0_CLIENTID }}
ARTIFACTS_AUTH0_CLIENTSECRET: ${{ secrets.ARTIFACTS_AUTH0_CLIENTSECRET }}
HNDRS_JWT_KEYSTOREPATH: ${{ secrets.ARTIFACTS_AUTH0_KEYSTOREPATH }}
run: |
./gradlew check
./gradlew check -Dspring.profiles.active=ci
12 changes: 11 additions & 1 deletion .github/workflows/hndrs-gradle-sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
analyse:
runs-on: ubuntu-latest

services:
mongodb:
image: mongo
ports:
- 27017:27017

steps:
- name: git checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -46,5 +52,9 @@ jobs:
- name: analyse
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
ARTIFACTS_AUTH0_DOMAIN: ${{ secrets.ARTIFACTS_AUTH0_DOMAIN }}
ARTIFACTS_AUTH0_CLIENTID: ${{ secrets.ARTIFACTS_AUTH0_CLIENTID }}
ARTIFACTS_AUTH0_CLIENTSECRET: ${{ secrets.ARTIFACTS_AUTH0_CLIENTSECRET }}
HNDRS_JWT_KEYSTOREPATH: ${{ secrets.ARTIFACTS_AUTH0_KEYSTOREPATH }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew check jacocoTestReport sonarqube --info
run: ./gradlew check jacocoTestReport sonarqube --info -Dspring.profiles.active=ci
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ out/

### VS Code ###
.vscode/

### Spring Boot ###
/config/*
!/config/*.example
1 change: 1 addition & 0 deletions application-ci.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
spring.data.mongodb.uri=mongodb://mongodb/local_artifacts?retryWrites=true&w=majority
4 changes: 4 additions & 0 deletions application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
logging.level.org.springframework.boot.autoconfigure=DEBUG
#Mongo DB
spring.data.mongodb.auto-index-creation=true
spring.data.mongodb.uri=mongodb://localhost/local_artifacts?retryWrites=true&w=majority
33 changes: 26 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.springframework.boot") version "2.4.3"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("org.sonarqube").version("3.1.1")
kotlin("jvm") version "1.4.30"
kotlin("plugin.spring") version "1.4.30"
id("org.springframework.boot")
id("io.spring.dependency-management")
id("org.sonarqube").version("3.3")
kotlin("jvm")
kotlin("plugin.spring")
kotlin("kapt")
jacoco
}

Expand All @@ -17,17 +18,32 @@ repositories {
mavenCentral()
}

dependencyManagement {
imports {
mavenBom("com.squareup.okhttp3:okhttp-bom:4.9.0")
}
}


dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
implementation("org.jetbrains.kotlin:kotlin-reflect")

implementation("com.auth0:auth0:1.33.0")
implementation("io.springfox:springfox-boot-starter:3.0.0")
//hndrs
implementation("io.hndrs:jsonapi-spring-boot-starter:1.0.0")
implementation("io.hndrs:jwt-auth-spring-boot-starter:1.0.0")

kapt(group = "org.springframework.boot", name = "spring-boot-configuration-processor")

implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(module = "mockito-core")
}
testImplementation("com.ninja-squad:springmockk:3.0.1")
}

sonarqube {
Expand All @@ -39,7 +55,7 @@ sonarqube {
}

jacoco {
toolVersion = "0.8.6"
toolVersion = "0.8.7"
}

tasks.withType<JacocoReport> {
Expand All @@ -59,4 +75,7 @@ tasks.withType<KotlinCompile> {

tasks.withType<Test> {
useJUnitPlatform()
System.getProperty("spring.profiles.active")?.let {
systemProperties.put("spring.profiles.active", it)
}
}
4 changes: 4 additions & 0 deletions config/application.properties.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hndrs.jwt.key-store-path=
artifacts.auth0.domain=
artifacts.auth0.client-id=
artifacts.auth0.client-secret=
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kotlinVersion=1.5.20
springDependencyManagement=1.0.11.RELEASE
springBootDependencies=2.5.3
17 changes: 17 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
rootProject.name = "artifacts"

pluginManagement {
val kotlinVersion: String by settings
val springDependencyManagement: String by settings
val springBootDependencies: String by settings

plugins {
id("org.springframework.boot").version(springBootDependencies)
id("io.spring.dependency-management").version(springDependencyManagement)
kotlin("jvm").version(kotlinVersion)
kotlin("plugin.spring").version(kotlinVersion)
kotlin("kapt").version(kotlinVersion)
id("idea")
}
repositories {
}
}
39 changes: 39 additions & 0 deletions src/main/kotlin/io/hndrs/artifacts/OpenApiConfiguration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.hndrs.artifacts

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.core.annotation.Order
import org.springframework.stereotype.Component
import springfox.documentation.builders.RequestHandlerSelectors
import springfox.documentation.service.Tag
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spi.DocumentationType.OAS_30
import springfox.documentation.spi.service.OperationBuilderPlugin
import springfox.documentation.spi.service.contexts.OperationContext
import springfox.documentation.spring.web.plugins.Docket
import springfox.documentation.swagger.common.SwaggerPluginSupport

@Configuration
class OpenApiConfiguration {


@Bean
fun docket(): Docket = Docket(OAS_30)
.tags(Tag("Artifacts Api", "analysis description"))
.select()
.apis(RequestHandlerSelectors.basePackage("io.hndrs"))
.build()
}

@Component
@Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER + 1)
class GlobalTag : OperationBuilderPlugin {
override fun supports(delimiter: DocumentationType): Boolean {
return delimiter == OAS_30
}

override fun apply(context: OperationContext) {
context.operationBuilder().tags(setOf("Artifacts Api"))
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.hndrs.artifacts.configuration

import com.auth0.client.auth.AuthAPI
import com.auth0.client.mgmt.ManagementAPI
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
@EnableConfigurationProperties(Auth0ConfigurationProperties::class)
class Auth0Configuration(private val properties: Auth0ConfigurationProperties) {

@Bean
fun managementApi(): ManagementAPI {
val authAPI = AuthAPI(
properties.domain,
properties.clientId,
properties.clientSecret
)

val accessToken = authAPI.requestToken("${properties.domain}/api/v2/").execute().accessToken

return ManagementAPI(properties.domain, accessToken)
}
}

@ConfigurationProperties(prefix = "artifacts.auth0")
open class Auth0ConfigurationProperties {

lateinit var domain: String

lateinit var clientId: String

lateinit var clientSecret: String


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package io.hndrs.artifacts.configuration

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package io.hndrs.artifacts.domain
package io.hndrs.artifacts.module.artifacts

import io.hndrs.api.response.JsonApiResponse
import io.hndrs.artifacts.shared.User
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class UserController {
class ArtifactsController {


@GetMapping("/user")
@GetMapping("/artifacts")
@JsonApiResponse
fun user(): User {
return User("id")
fun artifacts() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.hndrs.artifacts.module.organisation

import io.hndrs.api.response.JsonApiResponse
import io.swagger.annotations.ApiImplicitParam
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RestController

@RestController
class OrganisationArtifactsController {

@ApiImplicitParam(
name = "Authorization",
value = "Id Token",
required = true,
allowEmptyValue = false,
paramType = "header",
dataTypeClass = String::class,
example = "Bearer id_token"
)
@GetMapping("/organisations/{orgainsation_id}/artifacts")
@JsonApiResponse
fun organisationArtifacts(@PathVariable("orgainsation_id") organisationId: String) {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.hndrs.artifacts.module.organisation

import io.hndrs.api.response.JsonApiResponse
import io.hndrs.jwt.Identity
import io.swagger.annotations.ApiImplicitParam
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class OrganisationsController {

@ApiImplicitParam(
name = "Authorization",
value = "Id Token",
required = true,
allowEmptyValue = false,
paramType = "header",
dataTypeClass = String::class,
example = "Bearer id_token"
)
@GetMapping("/organisations")
@JsonApiResponse
fun organisation(@Identity user: Map<String, Any>) {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.hndrs.artifacts.module.project

import io.hndrs.api.response.JsonApiResponse
import io.hndrs.jwt.Identity
import io.swagger.annotations.ApiImplicitParam
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class ProjectsController {

@ApiImplicitParam(
name = "Authorization",
value = "Id Token",
required = true,
allowEmptyValue = false,
paramType = "header",
dataTypeClass = String::class,
example = "Bearer id_token"
)
@GetMapping("/projects")
@JsonApiResponse
fun projects(@Identity user: Map<String, Any>) {
}

}
26 changes: 26 additions & 0 deletions src/main/kotlin/io/hndrs/artifacts/module/team/TeamsController.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.hndrs.artifacts.module.team

import io.hndrs.api.response.JsonApiResponse
import io.hndrs.jwt.Identity
import io.swagger.annotations.ApiImplicitParam
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class TeamsController {

@ApiImplicitParam(
name = "Authorization",
value = "Id Token",
required = true,
allowEmptyValue = false,
paramType = "header",
dataTypeClass = String::class,
example = "Bearer id_token"
)
@GetMapping("/teams")
@JsonApiResponse
fun teams(@Identity user: Map<String, Any>) {
}

}
Loading