package org.sagebionetworks.bridge.config;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class BridgeConfigTest {

    @Before
    public void before() {
        System.setProperty("bridge.pwd", "when.the.password.is.not.a.password");
        System.setProperty("bridge.salt", "when.the.salt.is.some.random.sea.salt");
    }

    @After
    public void after() {
        System.clearProperty("bridge.pwd");
        System.clearProperty("bridge.salt");
        System.clearProperty("bridge.env");
    }

    @Test
    public void testDefault() {
        BridgeConfig config = new BridgeConfig();
        assertTrue(config.isStub());
        assertNull(config.getProperty("someFakePropertyThatDoesNotExist"));
    }

    @Test
    public void testEncryption() {
        BridgeConfig config = new BridgeConfig();
        assertEquals("example.value", config.getProperty("example.property"));
        assertEquals("example.value.encrypted", config.getProperty("example.property.encrypted"));
    }

    @Test
    public void testEnvironment() {
        System.setProperty("bridge.env", "dev");
        BridgeConfig config = new BridgeConfig();
        assertEquals("example.value.for.dev", config.getProperty("example.property"));
    }
}

@@ -475,24 +475,80 @@
 sea.salt%22);%0A
+        System.setProperty(%22bridge.user%22, %22unit.test%22);%0A
     %7D%0A%0A    @
@@ -660,32 +660,77 @@
 %22bridge.salt%22);%0A
+        System.clearProperty(%22bridge.user%22);%0A
         System.c
@@ -1493,11 +1493,177 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testUser() %7B%0A        BridgeConfig config = new BridgeConfig();%0A        assertEquals(%22unit.test%22, config.getProperty(%22bridge.user%22));%0A    %7D
 %0A%7D%0A

Add bridge.user to the config.