Removed redundant timeout handling for executeCommand
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / commons / ssh-lib / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / ssh / service / BlueprintSshLibPropertyServiceTest.kt
1 /*
2  *  Copyright © 2019 IBM.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16
17 package org.onap.ccsdk.cds.blueprintsprocessor.ssh.service
18
19 import org.junit.Test
20 import org.junit.runner.RunWith
21 import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertiesService
22 import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
23 import org.onap.ccsdk.cds.blueprintsprocessor.ssh.BasicAuthSshClientProperties
24 import org.onap.ccsdk.cds.blueprintsprocessor.ssh.BlueprintSshLibConfiguration
25 import org.springframework.beans.factory.annotation.Autowired
26 import org.springframework.test.context.ContextConfiguration
27 import org.springframework.test.context.TestPropertySource
28 import org.springframework.test.context.junit4.SpringRunner
29 import kotlin.test.assertEquals
30 import kotlin.test.assertNotNull
31
32 @RunWith(SpringRunner::class)
33 @ContextConfiguration(
34     classes = [
35         BlueprintSshLibConfiguration::class,
36         BlueprintPropertyConfiguration::class, BlueprintPropertiesService::class
37     ]
38 )
39 @TestPropertySource(
40     properties =
41         [
42             "blueprintsprocessor.sshclient.sample.type=basic-auth",
43             "blueprintsprocessor.sshclient.sample.host=127.0.0.1",
44             "blueprintsprocessor.sshclient.sample.port=22",
45             "blueprintsprocessor.sshclient.sample.password=1234",
46             "blueprintsprocessor.sshclient.sample.username=dummy"
47         ]
48 )
49 class BlueprintSshLibPropertyServiceTest {
50
51     @Autowired
52     lateinit var bluePrintSshLibPropertyService: BlueprintSshLibPropertyService
53
54     @Test
55     fun testRestClientProperties() {
56         val properties = bluePrintSshLibPropertyService
57             .sshClientProperties("blueprintsprocessor.sshclient.sample") as BasicAuthSshClientProperties
58         assertNotNull(properties, "failed to create property bean")
59         assertEquals(properties.host, "127.0.0.1", "failed to match host property")
60         assertEquals(properties.port, 22, "failed to match port property")
61         assertEquals(properties.password, "1234", "failed to match host property")
62         assertEquals(properties.username, "dummy", "failed to match host property")
63     }
64 }