Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
[#83] Tests clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Zajaczkowski committed Nov 18, 2014
1 parent 5f42a25 commit 1644f66
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 97 deletions.
2 changes: 1 addition & 1 deletion micro-infra-spring-property/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
compile("org.springframework.cloud:spring-cloud-config-server:$springCloudVersion") {
exclude group: 'ch.qos.logback', module: 'logback-classic'
}
compile "org.springframework.security:spring-security-rsa:1.0.0.M2"
compile "org.springframework.security:spring-security-rsa:1.0.0.M2" //Not needed when AES is used?
compile "org.eclipse.jgit:org.eclipse.jgit:2.3.1.201302201838-r"
compile "org.codehaus.groovy:groovy-all:$groovyVersion"
compile "org.aspectj:aspectjrt:1.8.3"
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.ofg.infrastructure.property

import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.cloud.autoconfigure.ConfigClientAutoConfiguration
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration

@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = ['org.springframework.cloud.autoconfigure'])
@ComponentScan(basePackageClasses = [ConfigClientAutoConfiguration.class])
class DecryptingPropertyTestApp {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ofg.infrastructure.property
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.cloud.autoconfigure.ConfigClientAutoConfiguration
import org.springframework.context.ConfigurableApplicationContext
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
Expand Down Expand Up @@ -75,7 +76,7 @@ class LoadingFromFileSystemTest extends AbstractIntegrationTest {

@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = ['org.springframework.cloud.autoconfigure'])
@ComponentScan(basePackageClasses = [ConfigClientAutoConfiguration.class])
class BasicApp {

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ package com.ofg.infrastructure.property.decrypt

import com.ofg.infrastructure.property.AbstractIntegrationTest
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.ConfigurableApplicationContext
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.PropertySource
import org.springframework.stereotype.Component
import spock.lang.Ignore
import spock.lang.Issue
import spock.lang.Shared

class DecryptingPropertyTest extends AbstractIntegrationTest {
Expand All @@ -15,7 +19,7 @@ class DecryptingPropertyTest extends AbstractIntegrationTest {

def setupSpec() {
System.setProperty("encrypt.key", "eKey") //To simulate setting environment variable
context = new SpringApplicationBuilder(DecryptingPropertyTestApp, TestConfigurationWithPropertySource)
context = new SpringApplicationBuilder(DecryptingPropertyTestApp, TestConfigurationWithPropertySource, ConfigurationPropertiesSettings)
.web(false)
.showBanner(false)
.properties("enc.prop:{cipher}f43b8323cd82a74aafa1fba5efdce529274b58f68145903e6cc7e460e07e0e20")
Expand All @@ -38,13 +42,27 @@ class DecryptingPropertyTest extends AbstractIntegrationTest {
}

@Ignore("Currently EnvironmentDecryptApplicationListener is run too early")
@Issue("https://github.com/spring-cloud/spring-cloud-config/issues/30")
def "should decrypt properties added with @PropertySource"() {
expect:
context.environment.getProperty("enc.propertySource.prop") == "enc.propertySource.prop.value"
}

@Ignore("Not supported")
def "should decrypt properties added with @ConfigurationProperties"() {
expect:
context.getBean(ConfigurationPropertiesSettings)?.configurationProperties == "enc.propertySource.prop.value"
}
}

@Configuration
@PropertySource("testConfigurationWithPropertySource.properties")
@PropertySource("classpath:testConfigurationWithPropertySource.properties")
@EnableConfigurationProperties
class TestConfigurationWithPropertySource {
}

@Component
@ConfigurationProperties(locations = "classpath:testConfigurationWithConfigurationProperties.properties", prefix = "enc")
class ConfigurationPropertiesSettings {
String configurationProperties
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.ofg.infrastructure.property.decrypt

import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.cloud.autoconfigure.ConfigClientAutoConfiguration
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration

@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = ['org.springframework.cloud.autoconfigure'])
@ComponentScan(basePackageClasses = [ConfigClientAutoConfiguration.class])
class DecryptingPropertyTestApp {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.ofg.infrastructure.property.decrypt

import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.security.crypto.encrypt.TextEncryptor

class EncryptorTestUtil {

static void main(String[] args) {
System.setProperty("encrypt.key", "eKey")
System.setProperty("APP_ENV", "prod")
System.setProperty("countryCode", "pl")
def context = new SpringApplicationBuilder(DecryptingPropertyTestApp).web(false).run()
def encryptor = context.getBean(TextEncryptor)
println "Encrypted: ${encryptor.encrypt("value to encrypt")}"
}
}
2 changes: 0 additions & 2 deletions micro-infra-spring-property/src/test/resources/foo.properties

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enc.configurationProperties={cipher}7b11e6e32bf28eb1820553c042d9a7302065229c6aa0c159cacd5e47d4f45f15817313409fd2945e628e1c55094cddd45b56a60f60a1f16a1d1f8b7e3ed2b1e9

0 comments on commit 1644f66

Please sign in to comment.