Add read permission for test logs file
[validation.git] / tests / os / lynis / lynis.robot
1 ##############################################################################
2 # Copyright (c) 2019 AT&T Intellectual Property.                             #
3 # Copyright (c) 2019 Nokia.                                                  #
4 #                                                                            #
5 # Licensed under the Apache License, Version 2.0 (the "License");            #
6 # you maynot use this file except in compliance with the License.            #
7 #                                                                            #
8 # You may obtain a copy of the License at                                    #
9 #       http://www.apache.org/licenses/LICENSE-2.0                           #
10 #                                                                            #
11 # Unless required by applicable law or agreed to in writing, software        #
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
14 # See the License for the specific language governing permissions and        #
15 # limitations under the License.                                             #
16 ##############################################################################
17
18 *** Settings ***
19 Documentation     Validation, Auditing Hardening Compliance
20 Library           SSHLibrary
21 Library           OperatingSystem
22 Library           BuiltIn
23 Library           Process
24 Suite Setup       Run Keywords
25 ...               Open Connection And Log In
26 ...               Install Lynis
27 Test Teardown     Download Logs
28 Suite Teardown    Run Keywords
29 ...               Uninstall Lynis
30 ...               Close All Connections
31
32 *** Variables ***
33 ${FULL_SUITE}  ${SUITE_NAME.replace(' ','_')}
34
35 *** Test Cases ***
36 Run Lynis Audit System
37     [Documentation]  Run Lynis
38     ${log} =  Set Variable  ${OUTPUT DIR}${/}${FULL_SUITE}.${TEST NAME.replace(' ','_')}.log
39     ${stdout}    ${rc} =  Execute Command  cd lynis && sudo ./lynis audit system --quick  return_rc=True
40     Append To File  ${log}  ${stdout}${\n}
41     Should Be Equal As Integers  ${rc}  0
42
43
44 *** Keywords ***
45 Open Connection And Log In
46     Open Connection  ${HOST}
47     Login With Public Key  ${USERNAME}  ${SSH_KEYFILE}
48
49 Install Lynis
50     [Documentation]  Install Lynis
51     Put File  /opt/akraino/lynis-remote.tar.gz
52     Execute Command  tar xzf lynis-remote.tar.gz && sudo chown -R 0:0 lynis
53
54 Uninstall Lynis
55     [Documentation]  Uninstall Lynis
56     Execute Command  rm lynis-remote.tar.gz
57     Execute Command  rm -rf ~/lynis /var/log/lynis.log /var/log/lynis-report.dat  sudo=True
58
59 Download Logs
60     [Documentation]  Downloading logs and removing them
61     Execute Command  chmod +r /var/log/lynis.log  sudo=True
62     SSHLibrary.Get File  /var/log/lynis.log  ${OUTPUT DIR}/lynis.log
63     Execute Command  rm /var/log/lynis.log  sudo=True
64     Execute Command  chmod +r /var/log/lynis-report.dat  sudo=True
65     SSHLibrary.Get File  /var/log/lynis-report.dat  ${OUTPUT DIR}/lynis-report.dat
66     Execute Command  rm /var/log/lynis-report.dat  sudo=True