Author: Rand Deeb / Information Security master student / ITMO University
This repository is a practical project in ITMO University
Manage GitHub scripts and documents
create Skills2022
directory inside the home directory using mkdir
- Create
Skills2022
directory - Initialize the local repository, Create
README.md
file and add it to the repo. - Create remote repo and add remote origin
- Had the error
Password support removed
and solve it using the following commands after create personal access token (explained in details in task troubleshooting). - push the commits to the remote repo using
push
command
We can create access token from your GitHub account, go to Settings => Developer Settings => Personal Access Token => Generate New Token (Give your password) => Fillup the form => click Generate token => Copy the generated Token
then use the following commands as in the step5 screenshot
$ git config --global user.name "your_github_username"
$ git config --global user.email "your_github_email"
$ git config -l
Manage WebServers through Ansible.
- Create
task2
directory inside theSkills2022
directory usingmkdir
- Enable the SSH server
- Copy
Desktop/labs/devnet-src/ansible/ansible-apache
files toSkills2022/task2
- Add the following to
hosts
file
[webservers]
192.0.2.3 ansible_ssh_user=devasc ansible_ssh_pass=Cisco123!
- Add the following to
ansible.cfg
config:
[defaults]
# hosts
inventory=./hosts
# RSA
host_key_checking = False
# retry files
retry_files_enable = False
- Add the following to the playbook file:
- hosts: webservers
become: yes
tasks:
- name: INSTALL APACHE2
apt: name=apache2 update_cache=yes state=latest
- name: ENABLED MOD_REWRITE
apache2_module: name=rewrite state=present
notify:
- RESTART APACHE2
- name: TESTING
command: /bin/echo test
handlers:
- name: RESTART APACHE2
service: name=apache2 state=restarted
N/A
Lets run the playbook and check using the following command
ansible-playbook -v WEBSERVER_INSTALLATION_AND_TESTING.yaml
As we can see nothing failed.
Manage Docker microservices
Create task3
directory inside the Skills2022
directory using mkdir
- Copy
Dockerfile
&startup.sh
from repohttps://github.com/cturra/docker-ntp
- Build with docker build
N/A
We can test using ntpdate
CI/CD Pipeline using Jenkins
N/A
Run and wait, it will clone the repo and execute the setup&run script and you will notice the success sign
Unit testing
create task5
directory inside the Skills2022
directory using mkdir
- Create
task.py
file contains the functions which we need to test:
def factors(n):
p = 2
f = list()
while n >= p*p :
if n % p == 0:
f.append(p)
n = int(n / p)
else:
p = p + 1
f.append(n)
return f
def is_prime(number):
if number <= 1:
return False
for n in range(2, number):
if number % n == 0:
return False
else:
return True
def vowels(text):
v = list()
for i in text:
if i in 'aeiouAEIOU':
v.append(i)
return v
- import
unittest
import unittest
- Add test class which inherits unittest.TestCase
- Convert the test functions into methods by adding
self
as the first argument
class TestTask5(unittest.TestCase):
def test_factors(self):
self.assertCountEqual(factors(1), [1], "Should be [1]")
self.assertCountEqual(factors(4), [2, 2], "Should be [2,2]")
self.assertCountEqual(factors(5), [5], "Should be [5]")
self.assertCountEqual(factors(6), [2,3], "Should be [2,3]")
def test_is_prime(self):
self.assertEqual(is_prime(-1), False, "Should be False")
self.assertEqual(is_prime(1), False, "Should be False")
self.assertEqual(is_prime(4), False, "Should be False")
self.assertEqual(is_prime(5), True, "Should be True")
self.assertEqual(is_prime(6), False, "Should be False")
def test_vowels(self):
self.assertCountEqual(vowels("ok"), ["o"], 'Should be ["o"]')
self.assertCountEqual(vowels("test"), ["e"], 'Should be ["e"]')
self.assertCountEqual(vowels("aeiouAEIOU"), ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"], 'Should be ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]')
self.assertCountEqual(vowels(""), [], "Should be []")
def test_len(self):
self.assertEqual(len(""), 0, "Should be 0")
self.assertEqual(len("test"), 4, "Should be 4")
self.assertEqual(len("test "), 5, "Should be 5")
self.assertEqual(len([1, 2]), 2, "Should be 2")
if __name__ == '__main__':
unittest.main()
N/A