From 11a0f65bae425baf09508e2d57c830f5cad69df5 Mon Sep 17 00:00:00 2001
From: gcontini <1121667+gcontini@users.noreply.github.com>
Date: 周六, 14 12月 2019 09:42:26 +0800
Subject: [PATCH] cleanup and change license generation parameters

---
 src/templates/licensecc_properties.h.in      |    5 
 test/library/LicenseLocator_test.cpp         |  122 ++++-------
 src/library/base/logger.c                    |    4 
 src/library/os/os-linux.c                    |  129 +++++-------
 test/functional/generate-license.cpp         |    2 
 test/library/LicenseReader_test.cpp          |   20 +
 src/templates/licensecc_properties_test.h.in |    2 
 src/library/os/CMakeLists.txt                |    3 
 README.md                                    |   25 +-
 /dev/null                                    |  195 -------------------
 src/library/licensecc.cpp                    |    2 
 extern/license-generator                     |    2 
 src/library/LicenseReader.cpp                |    1 
 .travis.yml                                  |   16 +
 src/library/locate/LocatorFactory.cpp        |   19 +
 test/functional/standard-license_test.cpp    |    5 
 src/library/locate/LocatorFactory.hpp        |    7 
 cmake/Findlcc.cmake                          |   19 +
 src/library/locate/ApplicationFolder.cpp     |    5 
 19 files changed, 187 insertions(+), 396 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 52c80db..925d1cc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -92,6 +92,22 @@
             "cd /root/open-license-manager/build && make && make install && VIRT_ENV=CONTAINER make test"
    - os: linux
      dist: bionic
+     name: "CentOS-8 Docker"
+     before_script: 
+        - docker run --name centos8_toconfigure -v `pwd`:/root/open-license-manager centos:centos8 /bin/bash -c \
+            "yum -y update && yum -y groupinstall 'Development Tools' && 
+             yum -y install wget cmake boost boost-devel openssl-devel zlib-devel && 
+             dnf -y --enablerepo=PowerTools install boost-static && 
+             wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1d.tar.gz && 
+             tar xzf OpenSSL_1_1_1d.tar.gz && cd openssl-OpenSSL_1_1_1d && 
+             ./config && make -j 8 && make install && 
+             cd /root/lcc-license-manager/build && cmake .."
+        - docker commit centos8_toconfigure centos8_configured
+     script: 
+        - docker run --name centos8_make -v `pwd`:/root/open-license-manager centos8_configured /bin/bash -c \
+            "cd /root/open-license-manager/build && make && make install && VIRT_ENV=CONTAINER make test"
+   - os: linux
+     dist: bionic
      name: "Ubuntu 18.04 - MinGW cross-compile for Windows x64"
      env:
         - CTEST_OUTPUT_ON_FAILURE=1      
diff --git a/README.md b/README.md
index 7331ee5..c6d077b 100644
--- a/README.md
+++ b/README.md
@@ -7,14 +7,12 @@
 [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
 [![Build Status](https://travis-ci.org/open-license-manager/open-license-manager.svg?branch=develop)](https://travis-ci.org/open-license-manager/open-license-manager)
 [![Codacy Badge](https://api.codacy.com/project/badge/Grade/62d6e1bb22d648bd85b6f3bc344a545a)](https://www.codacy.com/manual/gcontini/open-license-manager?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=open-license-manager/open-license-manager&amp;utm_campaign=Badge_Grade)
-[![Github Issues](![GitHub issues](https://img.shields.io/github/issues/open-license-manager/open-license-manager))](http://github.com/open-license-manager/open-license-manager/issues)
+[![Github Issues](https://img.shields.io/github/issues/open-license-manager/open-license-manager)](http://github.com/open-license-manager/open-license-manager/issues)
 
 It allows to protect the software you develop from unauthorized copies,
 limit the usage in time, to a specific set of machines, or prevent the usage in 
 virtualized environments. It is an Open License Manager that helps to keep your 
 software closed :smirk: . A comprehensive [list of features](https://github.com/open-license-manager/open-license-manager/wiki/features), and their status is available in the project wiki.
-
-** Warning! documentation outdated. We're in process of releasing the 2.0.0 verision that include a large update. Documentation still refers to 1.1.x series. In case of doubts look to .travis.yml file for hints on how to build the library. **
 
 ## License
 The project is donated to the community. It comes with a very large freedom of use for everyone, and it will always be. 
@@ -22,27 +20,30 @@
 
 ## Project Structure
 The software is made by 2 main sub-components:
-* a C++ library with a nice C api, `licensecc` with minimal (or no) external dependencies (the part you have to integrate in your software).
+* a C++ library with a nice C api, `licensecc` with minimal (or no) external dependencies (the part you have to integrate in your software) that is the project you're currently in.
 * a license generator lcc-license-generator `lcc` for customizing the library and generate the licenses.
  
-these modules are planned....
+The following modules are planned...
 * a license [backoffice](../../issues/7) in php (in order to handle multiple licenses).
 * a license debugger to be sent to the final customer when there are licensing problems. 
- * a [log descriptor](../../issues/8) in order to decrypt logs generated by the license system.
+* a [log descriptor](../../issues/8) in order to decrypt logs generated by the license system.
 
 # How to build
-Below an overview of the basic build procedure, you can find [detailed instructions](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library) for your environment in the wiki. 
+Below an overview of the basic build procedure, you can find detailed instructions for [linux](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library) or [windows](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library-win) in the wiki. 
 
 ## prerequisites
-* compilers: GCC (Linux) MINGW (Linux cross compile for Windows), MINGW or MSVC (Windows) 
-* tools    : cmake, git, make/ninja(linux)
-* libs     : If target is linux Openssl is required. Windows depends only on system libraries. Boost is necessary to build license generator and to run the tests but it's NOT a dependency of the `licensecc` library.
+* Operating system: Linux(Ubuntu, CentOS), Windows
+* compilers       : GCC (Linux) MINGW (Linux cross compile for Windows), MINGW or MSVC (Windows) 
+* tools           : cmake(>3.6), git, make/ninja(linux)
+* libs            : If target is linux Openssl is required. Windows depends only on system libraries. Boost is necessary to build license generator and to run the tests but it's NOT a dependency of the final `licensecc` library. 
 
+For a complete list of dependencies and supported environments see [the wiki](https://github.com/open-license-manager/open-license-manager/wiki/Dependencies)
+
+Clone the project. It has submodules, don't forget the `--recursive` option.
 
 ```
-git clone https://github.com/open-license-manager/open-license-manager.git
+git clone --recursive https://github.com/open-license-manager/open-license-manager.git
 cd open-license-manager/
-mkdir build
 cd build
 ```
 
diff --git a/cmake/Findlcc.cmake b/cmake/Findlcc.cmake
index 0f95a42..27f63b8 100644
--- a/cmake/Findlcc.cmake
+++ b/cmake/Findlcc.cmake
@@ -46,14 +46,16 @@
 find_package(PkgConfig)
 
 if(LCC_LOCATION)
-	# First search the PATH and specific locations.
-	find_program(LCC_EXECUTABLE
-	NAMES ${lcc_names} HINTS ${LCC_LOCATION} DOC "lcc command line client")
-	FIND_PACKAGE_HANDLE_STANDARD_ARGS(lcc FOUND_VAR LCC_FOUND
-                                       REQUIRED_VARS LCC_EXECUTABLE 
-                                       FAIL_MESSAGE "Error finding lcc executable. variable LCC_LOCATION non set correctly.")
-    add_executable(license_generator::lcc IMPORTED GLOBAL)                                            
-	set_property(TARGET license_generator::lcc PROPERTY IMPORTED_LOCATION ${LCC_EXECUTABLE})  
+	find_package(lcc HINTS ${LCC_LOCATION} CONFIG) #try to find it without looping on this module
+	if(NOT lcc_FOUND)
+		find_program(LCC_EXECUTABLE
+		NAMES ${lcc_names} HINTS ${LCC_LOCATION} DOC "lcc command line client")
+		FIND_PACKAGE_HANDLE_STANDARD_ARGS(lcc FOUND_VAR LCC_FOUND
+        	                               REQUIRED_VARS LCC_EXECUTABLE 
+            	                           FAIL_MESSAGE "Error finding lcc executable. variable LCC_LOCATION non set correctly.")
+    	add_executable(license_generator::lcc IMPORTED GLOBAL)                                            
+		set_property(TARGET license_generator::lcc PROPERTY IMPORTED_LOCATION ${LCC_EXECUTABLE})
+	ENDIF(NOT lcc_FOUND)
 ELSE(LCC_LOCATION)
 	find_package(lcc HINTS ${CMAKE_BINARY_DIR} CONFIG) #try to find it without looping on this module
 
@@ -76,6 +78,7 @@
 		    set(failure_messge  "All the options to find lcc executable failed. And i can't compile one from source GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
 		endif()
 		add_subdirectory("${PROJECT_SOURCE_DIR}/extern/license-generator")
+		set(lcc_FOUND TRUE)
 	ENDIF(NOT lcc_FOUND)
 ENDIF(LCC_LOCATION)
 
diff --git a/extern/license-generator b/extern/license-generator
index 33b74eb..c40c095 160000
--- a/extern/license-generator
+++ b/extern/license-generator
@@ -1 +1 @@
-Subproject commit 33b74eb3fcf786dcf1a2f53b038917437cbeb8cd
+Subproject commit c40c0951e77c012a1c4043182c88ae5fe185efea
diff --git a/src/library/LicenseReader.cpp b/src/library/LicenseReader.cpp
index a85b1ca..7390f3c 100644
--- a/src/library/LicenseReader.cpp
+++ b/src/library/LicenseReader.cpp
@@ -44,7 +44,6 @@
 LicenseReader::LicenseReader(const LicenseLocation *licenseLocation) : licenseLocation(licenseLocation) {}
 
 EventRegistry LicenseReader::readLicenses(const string &product, vector<FullLicenseInfo> &licenseInfoOut) const {
-	vector<string> diskFiles;
 	vector<unique_ptr<locate::LocatorStrategy>> locator_strategies;
 	FUNCTION_RETURN ret = locate::LocatorFactory::get_active_strategies(locator_strategies, licenseLocation);
 	EventRegistry eventRegistry;
diff --git a/src/library/base/logger.c b/src/library/base/logger.c
index a6dc5f3..30db85d 100644
--- a/src/library/base/logger.c
+++ b/src/library/base/logger.c
@@ -26,7 +26,7 @@
 
 static void getLogFname(char* logpath) {
 #ifdef __unix__
-	char const *folder = getenv("TMPDIR");
+	const char *folder = getenv("TMPDIR");
 	if (folder == 0) {
 		folder = "/tmp";
 	}
@@ -42,10 +42,10 @@
 }
 
 void _log(const char* format, ...) {
-	char logpath[MAX_PATH];
 	va_list args;
 	char * buffer;
 	if (logFile == NULL) {
+		char logpath[MAX_PATH];
 		getLogFname(logpath);
 		logFile = fopen(logpath, "a");
 		if (logFile == NULL) {
diff --git a/src/library/licensecc.cpp b/src/library/licensecc.cpp
index c7484c3..8860311 100644
--- a/src/library/licensecc.cpp
+++ b/src/library/licensecc.cpp
@@ -23,9 +23,9 @@
 void print_error(char out_buffer[256], LicenseInfo* licenseInfo) {}
 
 bool identify_pc(IDENTIFICATION_STRATEGY pc_id_method, char* chbuffer, size_t bufSize) {
-	PcSignature identifier_out;
 	FUNCTION_RETURN result = FUNC_RET_BUFFER_TOO_SMALL;
 	if (bufSize >= sizeof(PcSignature)) {
+		PcSignature identifier_out;
 		result = generate_user_pc_signature(identifier_out, pc_id_method);
 		strncpy(chbuffer, identifier_out, bufSize);
 	}
diff --git a/src/library/locate/ApplicationFolder.cpp b/src/library/locate/ApplicationFolder.cpp
index 215d477..8741988 100644
--- a/src/library/locate/ApplicationFolder.cpp
+++ b/src/library/locate/ApplicationFolder.cpp
@@ -7,8 +7,10 @@
 #include <fstream>
 #include <sstream>
 #include <string>
+#include <iostream>
 
 #include <licensecc/datatypes.h>
+#include <licensecc_properties.h>
 
 #include "../base/logger.h"
 #include "../base/base.h"
@@ -16,7 +18,6 @@
 #include "../base/FileUtils.hpp"
 #include "../os/os.h"
 #include "ApplicationFolder.hpp"
-#include <iostream>
 
 namespace license {
 namespace locate {
@@ -32,7 +33,7 @@
 	const FUNCTION_RETURN fret = getModuleName(fname);
 	if (fret == FUNC_RET_OK) {
 		const string module_name = remove_extension(fname);
-		const string temptativeLicense = string(module_name) + ".lic";
+		const string temptativeLicense = string(module_name) + LICENSE_FILE_EXTENSION;
 		ifstream f(temptativeLicense.c_str());
 		if (f.good()) {
 			diskFiles.push_back(temptativeLicense);
diff --git a/src/library/locate/LocatorFactory.cpp b/src/library/locate/LocatorFactory.cpp
index 667a387..9b77b06 100644
--- a/src/library/locate/LocatorFactory.cpp
+++ b/src/library/locate/LocatorFactory.cpp
@@ -5,8 +5,6 @@
  *      Author: Gabriele Contini
  */
 
-#include "licensecc_properties.h"
-
 #include "LocatorStrategy.hpp"
 #include "LocatorFactory.hpp"
 #include "ApplicationFolder.hpp"
@@ -16,16 +14,19 @@
 
 namespace license {
 namespace locate {
+static std::vector<std::unique_ptr<LocatorStrategy>> extra_strategies;
 
+bool LocatorFactory::find_license_near_moduleb = FIND_LICENSE_NEAR_MODULE;
+bool LocatorFactory::find_license_with_env_varb = FIND_LICENSE_WITH_ENV_VAR;
 FUNCTION_RETURN LocatorFactory::get_active_strategies(std::vector<std::unique_ptr<LocatorStrategy>> &strategies,
 													  const LicenseLocation *locationHint) {
-#if (FIND_LICENSE_NEAR_MODULE)
-	strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new ApplicationFolder()));
-#endif
-#if (FIND_LICENSE_WITH_ENV_VAR)
-	strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new EnvironmentVarLocation()));
-	strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new EnvironmentVarData()));
-#endif
+	if (find_license_near_moduleb) {
+		strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new ApplicationFolder()));
+	}
+	if (find_license_with_env_varb) {
+		strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new EnvironmentVarLocation()));
+		strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new EnvironmentVarData()));
+	}
 	if (locationHint != nullptr) {
 		strategies.push_back(std::unique_ptr<LocatorStrategy>((LocatorStrategy *)new ExternalDefinition(locationHint)));
 	}
diff --git a/src/library/locate/LocatorFactory.hpp b/src/library/locate/LocatorFactory.hpp
index 9c54b51..9a1f22c 100644
--- a/src/library/locate/LocatorFactory.hpp
+++ b/src/library/locate/LocatorFactory.hpp
@@ -5,6 +5,7 @@
 #include <string>
 #include <vector>
 #include <licensecc/datatypes.h>
+#include <licensecc_properties.h>
 
 #include "../base/base.h"
 #include "LocatorStrategy.hpp"
@@ -14,16 +15,18 @@
 
 class LocatorFactory {
 private:
+	static bool find_license_near_moduleb;
+	static bool find_license_with_env_varb;
 	inline LocatorFactory() {
 	}
 	inline ~LocatorFactory() {
 	}
 public:
-
 	static FUNCTION_RETURN get_active_strategies(
 			std::vector<std::unique_ptr<LocatorStrategy>> &strategiesOut,
 			const LicenseLocation *locationHint);
-
+	static void find_license_near_module(bool enable) { find_license_near_moduleb = enable; }
+	static void find_license_with_env_var(bool enable) { find_license_with_env_varb = enable; }
 };
 
 }
diff --git a/src/library/os/CMakeLists.txt b/src/library/os/CMakeLists.txt
index 6648630..1e3bc46 100644
--- a/src/library/os/CMakeLists.txt
+++ b/src/library/os/CMakeLists.txt
@@ -1,6 +1,3 @@
-target_sources(licensecc_static PRIVATE 
-	 ${CMAKE_CURRENT_SOURCE_DIR}/os.c)
-
 IF(UNIX OR OPENSSL_FOUND)
 	IF(UNIX)
 		target_sources(licensecc_static PRIVATE
diff --git a/src/library/os/os-linux.c b/src/library/os/os-linux.c
index ddfca4b..861bb19 100644
--- a/src/library/os/os-linux.c
+++ b/src/library/os/os-linux.c
@@ -22,15 +22,14 @@
  *@param uuid uuid as read in /dev/disk/by-uuid
  *@param buffer_out: unsigned char buffer[8] output buffer for result
  */
-static void parseUUID(const char *uuid, unsigned char *buffer_out,
-		unsigned int out_size) {
+static void parseUUID(const char *uuid, unsigned char *buffer_out, unsigned int out_size) {
 	size_t len;
 	unsigned int i, j;
 	char *hexuuid;
 	unsigned char cur_character;
-	//remove characters not in hex set
+	// remove characters not in hex set
 	len = strlen(uuid);
-	hexuuid = (char*) malloc(sizeof(char) * strlen(uuid));
+	hexuuid = (char *)malloc(sizeof(char) * strlen(uuid));
 	memset(buffer_out, 0, out_size);
 	memset(hexuuid, 0, sizeof(char) * strlen(uuid));
 
@@ -39,7 +38,7 @@
 			hexuuid[j] = uuid[i];
 			j++;
 		} else {
-			//skip
+			// skip
 			continue;
 		}
 	}
@@ -77,11 +76,11 @@
 		tmpDrives = diskInfos;
 	} else {
 		maxDrives = MAX_UNITS;
-		tmpDrives = (DiskInfo*) malloc(sizeof(DiskInfo) * maxDrives);
+		tmpDrives = (DiskInfo *)malloc(sizeof(DiskInfo) * maxDrives);
 	}
 	memset(tmpDrives, 0, sizeof(DiskInfo) * maxDrives);
-	statDrives = (__ino64_t*) malloc(maxDrives * sizeof(__ino64_t ));
-	memset(statDrives, 0, sizeof(__ino64_t ) * maxDrives);
+	statDrives = (__ino64_t *)malloc(maxDrives * sizeof(__ino64_t));
+	memset(statDrives, 0, sizeof(__ino64_t) * maxDrives);
 
 	aFile = setmntent("/proc/mounts", "r");
 	if (aFile == NULL) {
@@ -93,12 +92,9 @@
 
 	currentDrive = 0;
 	while (NULL != (ent = getmntent(aFile))) {
-		if ((strncmp(ent->mnt_type, "ext", 3) == 0
-				|| strncmp(ent->mnt_type, "xfs", 3) == 0
-				|| strncmp(ent->mnt_type, "vfat", 4) == 0
-				|| strncmp(ent->mnt_type, "ntfs", 4) == 0)
-				&& ent->mnt_fsname != NULL
-				&& strncmp(ent->mnt_fsname, "/dev/", 5) == 0) {
+		if ((strncmp(ent->mnt_type, "ext", 3) == 0 || strncmp(ent->mnt_type, "xfs", 3) == 0 ||
+			 strncmp(ent->mnt_type, "vfat", 4) == 0 || strncmp(ent->mnt_type, "ntfs", 4) == 0) &&
+			ent->mnt_fsname != NULL && strncmp(ent->mnt_fsname, "/dev/", 5) == 0) {
 			if (stat(ent->mnt_fsname, &mount_stat) == 0) {
 				drive_found = -1;
 				for (i = 0; i < currentDrive; i++) {
@@ -108,9 +104,8 @@
 				}
 				if (drive_found == -1) {
 					LOG_DEBUG("mntent: %s %s %d\n", ent->mnt_fsname, ent->mnt_dir,
-							(unsigned long int)mount_stat.st_ino);
-					strncpy(tmpDrives[currentDrive].device, ent->mnt_fsname,
-							255 - 1);
+							  (unsigned long int)mount_stat.st_ino);
+					strncpy(tmpDrives[currentDrive].device, ent->mnt_fsname, 255 - 1);
 					statDrives[currentDrive] = mount_stat.st_ino;
 					drive_found = currentDrive;
 					currentDrive++;
@@ -144,17 +139,12 @@
 			if (stat(cur_dir, &sym_stat) == 0) {
 				for (i = 0; i < currentDrive; i++) {
 					if (sym_stat.st_ino == statDrives[i]) {
-						parseUUID(dir->d_name, tmpDrives[i].disk_sn,
-								sizeof(tmpDrives[i].disk_sn));
+						parseUUID(dir->d_name, tmpDrives[i].disk_sn, sizeof(tmpDrives[i].disk_sn));
 #ifdef _DEBUG
 						VALGRIND_CHECK_VALUE_IS_DEFINED(tmpDrives[i].device);
 
-						LOG_DEBUG("uuid %d %s %02x%02x%02x%02x\n", i,
-								tmpDrives[i].device,
-								tmpDrives[i].disk_sn[0],
-								tmpDrives[i].disk_sn[1],
-								tmpDrives[i].disk_sn[2],
-								tmpDrives[i].disk_sn[3]);
+						LOG_DEBUG("uuid %d %s %02x%02x%02x%02x\n", i, tmpDrives[i].device, tmpDrives[i].disk_sn[0],
+								  tmpDrives[i].disk_sn[1], tmpDrives[i].disk_sn[2], tmpDrives[i].disk_sn[3]);
 #endif
 					}
 				}
@@ -171,8 +161,7 @@
 					for (i = 0; i < currentDrive; i++) {
 						if (sym_stat.st_ino == statDrives[i]) {
 							strncpy(tmpDrives[i].label, dir->d_name, 255 - 1);
-							printf("label %d %s %s\n", i, tmpDrives[i].label,
-									tmpDrives[i].device);
+							printf("label %d %s %s\n", i, tmpDrives[i].label, tmpDrives[i].device);
 						}
 					}
 				}
@@ -202,24 +191,20 @@
 	return result;
 }
 
-void os_initialize() {
-
-}
+void os_initialize() {}
 
 static void _getCpuid(unsigned int *p, unsigned int ax) {
-	__asm __volatile
-	( "movl %%ebx, %%esi\n\t"
-			"cpuid\n\t"
-			"xchgl %%ebx, %%esi"
-			: "=a" (p[0]), "=S" (p[1]),
-			"=c" (p[2]), "=d" (p[3])
-			: "0" (ax)
-	);
+	__asm __volatile(
+		"movl %%ebx, %%esi\n\t"
+		"cpuid\n\t"
+		"xchgl %%ebx, %%esi"
+		: "=a"(p[0]), "=S"(p[1]), "=c"(p[2]), "=d"(p[3])
+		: "0"(ax));
 }
 
 FUNCTION_RETURN getCpuId(unsigned char identifier[6]) {
 	unsigned int i;
-	unsigned int cpuinfo[4] = { 0, 0, 0, 0 };
+	unsigned int cpuinfo[4] = {0, 0, 0, 0};
 	_getCpuid(cpuinfo, 0);
 	for (i = 0; i < 3; i++) {
 		identifier[i * 2] = cpuinfo[i] & 0xFF;
@@ -228,11 +213,11 @@
 	return FUNC_RET_OK;
 }
 
-//0=NO 1=Docker/Lxc
+// 0=NO 1=Docker/Lxc
 static int checkContainerProc() {
-	//in docer /proc/self/cgroups contains the "docker" or "lxc" string
-	//https://stackoverflow.com/questions/23513045/how-to-check-if-a-process-is-running-inside-docker-container
-	char path[MAX_PATH] = { 0 };
+	// in docer /proc/self/cgroups contains the "docker" or "lxc" string
+	// https://stackoverflow.com/questions/23513045/how-to-check-if-a-process-is-running-inside-docker-container
+	char path[MAX_PATH] = {0};
 	char proc_path[MAX_PATH], pidStr[64];
 	pid_t pid = getpid();
 	sprintf(pidStr, "%d", pid);
@@ -240,49 +225,47 @@
 	strcat(proc_path, pidStr);
 	strcat(proc_path, "/cgroup");
 
-    FILE * fp;
-    char * line = NULL;
-    size_t len = 0;
-    ssize_t read;
-    int result = 0;
+	FILE *fp;
+	char *line = NULL;
+	size_t len = 0;
+	ssize_t read;
+	int result = 0;
 
-    fp = fopen(proc_path, "r");
-    if (fp == NULL) {
-        return 0;
-    }
+	fp = fopen(proc_path, "r");
+	if (fp == NULL) {
+		return 0;
+	}
 
-    while ((read = getline(&line, &len, fp)) != -1 && result == 0) {
-    	//line[len]=0;
-        //printf("Retrieved line of length %zu:\n", read);
-        //printf("%s", line);
-    	if(strstr(line, "docker") != NULL || strstr(line, "lxc") != NULL) {
-    	    result = 1;
-    	}
-    }
+	while ((read = getline(&line, &len, fp)) != -1 && result == 0) {
+		// line[len]=0;
+		// printf("Retrieved line of length %zu:\n", read);
+		// printf("%s", line);
+		if (strstr(line, "docker") != NULL || strstr(line, "lxc") != NULL) {
+			result = 1;
+		}
+	}
 
-    fclose(fp);
-    if(line) free(line);
+	fclose(fp);
+	if (line) free(line);
 	return result;
 }
 
-//0=NO 1=Docker/Lxc
-static int checkLXC() {
-	return (access("/var/run/systemd/container",F_OK)==0) ? 1:0;
-}
+// 0=NO 1=Docker/Lxc
+static int checkLXC() { return (access("/var/run/systemd/container", F_OK) == 0) ? 1 : 0; }
 
 VIRTUALIZATION getVirtualization() {
 	VIRTUALIZATION result = NONE;
 	int isContainer = checkContainerProc();
 	if (isContainer == 1) {
 		result = CONTAINER;
-	} else if(checkLXC()){
+	} else if (checkLXC()) {
 		result = CONTAINER;
 	}
 	return result;
 
-//http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
-//
-//bool rc = true;
+	// http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
+	//
+	// bool rc = true;
 	/*__asm__ (
 	 "push   %edx\n"
 	 "push   %ecx\n"
@@ -299,7 +282,7 @@
 	 "pop    %edx \n"
 	 );*/
 
-	//systemd-detect-virt
+	// systemd-detect-virt
 	return NONE;
 }
 
@@ -315,7 +298,7 @@
 
 FUNCTION_RETURN getOsSpecificIdentifier(unsigned char identifier[6]) {
 #if USE_DBUS
-	char* dbus_id = dbus_get_local_machine_id();
+	char *dbus_id = dbus_get_local_machine_id();
 	if (dbus_id == NULL) {
 		return FUNC_RET_ERROR;
 	}
@@ -329,7 +312,7 @@
 
 FUNCTION_RETURN getModuleName(char buffer[MAX_PATH]) {
 	FUNCTION_RETURN result;
-	char path[MAX_PATH] = { 0 };
+	char path[MAX_PATH] = {0};
 	char proc_path[MAX_PATH], pidStr[64];
 	pid_t pid = getpid();
 	sprintf(pidStr, "%d", pid);
diff --git a/src/library/os/os.c b/src/library/os/os.c
deleted file mode 100644
index ed602ac..0000000
--- a/src/library/os/os.c
+++ /dev/null
@@ -1,195 +0,0 @@
-#include "os.h"
-#include "../base/logger.h"
-#include <public_key.h>
-#include <stdio.h>
-
-#ifdef __linux__
-
-#include <openssl/pem.h>
-/*
-static void free_resources(EVP_PKEY* pkey, EVP_MD_CTX* mdctx) {
-	if (pkey) {
-		EVP_PKEY_free(pkey);
-	}
-	if (mdctx) {
-		EVP_MD_CTX_destroy(mdctx);
-	}
-}*/
-/*
-FUNCTION_RETURN verifySignature(const char* stringToVerify,
-		const char* signatureB64) {
-	EVP_MD_CTX *mdctx = NULL;
-	const char pubKey[] = PUBLIC_KEY;
-	int func_ret = 0;
-
-	BIO* bio = BIO_new_mem_buf((void*) (pubKey), strlen(pubKey));
-	RSA *rsa = PEM_read_bio_RSAPublicKey(bio, NULL, NULL, NULL);
-	BIO_free(bio);
-	if (rsa == NULL) {
-		LOG_ERROR("Error reading public key");
-		return FUNC_RET_ERROR;
-	}
-	EVP_PKEY *pkey = EVP_PKEY_new();
-	EVP_PKEY_assign_RSA(pkey, rsa);
-
-	/*BIO* bo = BIO_new(BIO_s_mem());
-	 BIO_write(bo, pubKey, strlen(pubKey));
-	 RSA *key = 0;
-	 PEM_read_bio_RSAPublicKey(bo, &key, 0, 0);
-	 BIO_free(bo);*/
-/*
-//RSA* rsa = EVP_PKEY_get1_RSA( key );
-//RSA * pubKey = d2i_RSA_PUBKEY(NULL, <der encoded byte stream pointer>, <num bytes>);
-	unsigned char buffer[512];
-	BIO* b64 = BIO_new(BIO_f_base64());
-	BIO* encoded_signature = BIO_new_mem_buf((void *) signatureB64,
-			strlen(signatureB64));
-	BIO* biosig = BIO_push(b64, encoded_signature);
-	BIO_set_flags(biosig, BIO_FLAGS_BASE64_NO_NL); //Do not use newlines to flush buffer
-	unsigned int len = BIO_read(biosig, (void *) buffer, strlen(signatureB64));
-//Can test here if len == decodeLen - if not, then return an error
-	buffer[len] = 0;
-
-	BIO_free_all(biosig);
-
-	if (!(mdctx = EVP_MD_CTX_create())) {
-		free_resources(pkey, mdctx);
-		LOG_ERROR("Error creating context");
-		return FUNC_RET_ERROR;
-	}
-	if (1 != EVP_DigestVerifyInit(mdctx, NULL, EVP_sha256(), NULL, pkey)) {
-		LOG_ERROR("Error initializing digest");
-		free_resources(pkey, mdctx);
-		return FUNC_RET_ERROR;
-	}
-	int en = strlen(stringToVerify);
-	func_ret = EVP_DigestVerifyUpdate(mdctx, stringToVerify, en);
-	if (1 != func_ret) {
-		LOG_ERROR("Error verifying digest %d", func_ret);
-		free_resources(pkey, mdctx);
-		return FUNC_RET_ERROR;
-	}
-	FUNCTION_RETURN result;
-	func_ret = EVP_DigestVerifyFinal(mdctx, buffer, len);
-	if (1 != func_ret) {
-		LOG_ERROR("Error verifying digest %d", func_ret);
-	}
-	result = (1 == func_ret ? FUNC_RET_OK : FUNC_RET_ERROR);
-
-	free_resources(pkey, mdctx);
-	return result;
-}*/
-
-#else
-
-#include <iphlpapi.h>
-#include <windows.h>
-#pragma comment(lib, "IPHLPAPI.lib")
-
-unsigned char* unbase64(const char* ascii, int len, int *flen);
-
-static void printHash(HCRYPTHASH* hHash) {
-	BYTE *pbHash;
-	DWORD dwHashLen;
-	DWORD dwHashLenSize = sizeof(DWORD);
-	char* hashStr;
-	unsigned int i;
-
-	if (CryptGetHashParam(*hHash, HP_HASHSIZE, (BYTE *) &dwHashLen,
-			&dwHashLenSize, 0)) {
-		pbHash = (BYTE*) malloc(dwHashLen);
-		hashStr = (char*) malloc(dwHashLen * 2 + 1);
-		if (CryptGetHashParam(*hHash, HP_HASHVAL, pbHash, &dwHashLen, 0)) {
-			for (i = 0; i < dwHashLen; i++) {
-				sprintf(&hashStr[i * 2], "%02x", pbHash[i]);
-			} LOG_DEBUG("Hash to verify: %s", hashStr);
-		}
-		free(pbHash);
-		free(hashStr);
-	}
-}
-
-FUNCTION_RETURN verifySignature(const char* stringToVerify,
-		const char* signatureB64) {
-	//--------------------------------------------------------------------
-	// Declare variables.
-	//
-	// hProv:           Cryptographic service provider (CSP). This example
-	//                  uses the Microsoft Enhanced Cryptographic
-	//                  Provider.
-	// hKey:            Key to be used. In this example, you import the
-	//                  key as a PLAINTEXTKEYBLOB.
-	// dwBlobLen:       Length of the plaintext key.
-	// pbKeyBlob:       Pointer to the exported key.
-	BYTE pubKey[] = PUBLIC_KEY;
-
-	HCRYPTPROV hProv = 0;
-	HCRYPTKEY hKey = 0;
-	HCRYPTHASH hHash = 0;
-	DWORD dwSigLen;
-	BYTE* sigBlob;
-
-	//--------------------------------------------------------------------
-	// Acquire a handle to the CSP.
-
-	if (!CryptAcquireContext(&hProv,
-	NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
-		// If the key container cannot be opened, try creating a new
-		// container by specifying a container name and setting the
-		// CRYPT_NEWKEYSET flag.
-		LOG_INFO("Error in AcquireContext 0x%08x \n", GetLastError());
-		if (NTE_BAD_KEYSET == (long)GetLastError()) {
-			if (!CryptAcquireContext(&hProv, "license++verify",
-					MS_ENHANCED_PROV, PROV_RSA_FULL,
-					CRYPT_NEWKEYSET | CRYPT_VERIFYCONTEXT)) {
-				LOG_ERROR("Error in AcquireContext 0x%08x \n", GetLastError());
-				return FUNC_RET_ERROR;
-			}
-		} else {
-			LOG_ERROR(" Error in AcquireContext 0x%08x \n", GetLastError());
-			return FUNC_RET_ERROR;
-		}
-	}
-
-	// Use the CryptImportKey function to import the PLAINTEXTKEYBLOB
-	// BYTE array into the key container. The function returns a
-	// pointer to an HCRYPTKEY variable that contains the handle of
-	// the imported key.
-	if (!CryptImportKey(hProv, &pubKey[0], sizeof(pubKey), 0, 0, &hKey)) {
-		LOG_ERROR("Error 0x%08x in importing the PublicKey \n", GetLastError());
-		return FUNC_RET_ERROR;
-	}
-
-	if (CryptCreateHash(hProv, CALG_SHA1, 0, 0, &hHash)) {
-		LOG_DEBUG("Hash object created.");
-	} else {
-		LOG_ERROR("Error in hash creation 0x%08x ", GetLastError());
-		CryptReleaseContext(hProv, 0);
-		return FUNC_RET_ERROR;
-	}
-
-	if (!CryptHashData(hHash, (const BYTE*)stringToVerify, (DWORD) strlen(stringToVerify), 0)) {
-		LOG_ERROR("Error in hashing data 0x%08x ", GetLastError());
-		CryptDestroyHash(hHash);
-		CryptReleaseContext(hProv, 0);
-		return FUNC_RET_ERROR;
-	}
-#ifdef _DEBUG
-	LOG_DEBUG("Lenght %d, hashed Data: [%s]", strlen(stringToVerify), stringToVerify);
-	printHash(&hHash);
-#endif
-	sigBlob = unbase64(signatureB64, (int) strlen(signatureB64), (int*)&dwSigLen);
-	LOG_DEBUG("raw signature lenght %d", dwSigLen);
-	if (!CryptVerifySignature(hHash, sigBlob, dwSigLen, hKey, NULL, 0)) {
-		LOG_ERROR("Signature not validated!  0x%08x ", GetLastError());
-		free(sigBlob);
-		CryptDestroyHash(hHash);
-		CryptReleaseContext(hProv, 0);
-		return FUNC_RET_ERROR;
-	}
-	CryptDestroyHash(hHash);
-	free(sigBlob);
-	CryptReleaseContext(hProv, 0);
-	return FUNC_RET_OK;
-}
-#endif
diff --git a/src/templates/licensecc_properties.h.in b/src/templates/licensecc_properties.h.in
index 1b18b8d..c1af888 100644
--- a/src/templates/licensecc_properties.h.in
+++ b/src/templates/licensecc_properties.h.in
@@ -4,9 +4,10 @@
 #define LCC_PROJECT_NAME "@LCC_PROJECT_NAME@"
 
 //License retrieval configuration
-#define FIND_LICENSE_NEAR_MODULE 1
-#define FIND_LICENSE_WITH_ENV_VAR 0
+#define FIND_LICENSE_NEAR_MODULE true
+#define FIND_LICENSE_WITH_ENV_VAR false
 
+#define LICENSE_FILE_EXTENSION ".lic"
 #define LICENSE_LOCATION_ENV_VAR "LICENSE_LOCATION"
 #define LICENSE_DATA_ENV_VAR "LICENSE_DATA"
 
diff --git a/src/templates/licensecc_properties_test.h.in b/src/templates/licensecc_properties_test.h.in
index 071b788..69cf35d 100644
--- a/src/templates/licensecc_properties_test.h.in
+++ b/src/templates/licensecc_properties_test.h.in
@@ -19,7 +19,7 @@
  * command line parameters 
  */
 #define PARAM_BASE64 "base64"
-#define PARAM_LICENSE_NAME "license-name"
+#define PARAM_LICENSE_OUTPUT "output-file-name"
 #define PARAM_PRODUCT_NAME "product-name"
 #define PARAM_PROJECT_FOLDER "project-folder"
 #define PARAM_PRIMARY_KEY "primary-key"
diff --git a/test/functional/generate-license.cpp b/test/functional/generate-license.cpp
index 3aa07f9..8ef9477 100644
--- a/test/functional/generate-license.cpp
+++ b/test/functional/generate-license.cpp
@@ -37,7 +37,7 @@
 	stringstream ss;
 	ss << LCC_EXE << " license issue";
 	ss << " --" PARAM_PRIMARY_KEY " " << LCC_PROJECT_PRIVATE_KEY;
-	ss << " --" PARAM_LICENSE_NAME " " << license_name;
+	ss << " --" PARAM_LICENSE_OUTPUT " " << license_fname_s;
 	ss << " --" PARAM_PROJECT_FOLDER " " << LCC_TEST_LICENSES_PROJECT;
 
 	for (int i = 0; i < other_args.size(); i++) {
diff --git a/test/functional/standard-license_test.cpp b/test/functional/standard-license_test.cpp
index 0378607..669ca46 100644
--- a/test/functional/standard-license_test.cpp
+++ b/test/functional/standard-license_test.cpp
@@ -17,7 +17,10 @@
 using namespace license;
 using namespace std;
 
-BOOST_AUTO_TEST_CASE( standard_lic_file ) {
+/**
+ * Test a generic license with no expiry neither client id.
+ */
+BOOST_AUTO_TEST_CASE(test_generic_license) {
 	const vector<string> extraArgs;
 	const string licLocation = generate_license("standard_license", extraArgs);
 	/* */
diff --git a/test/library/LicenseLocator_test.cpp b/test/library/LicenseLocator_test.cpp
index 6110f34..6c83fc0 100644
--- a/test/library/LicenseLocator_test.cpp
+++ b/test/library/LicenseLocator_test.cpp
@@ -27,32 +27,30 @@
 using namespace std;
 using namespace boost::filesystem;
 
-static boost::optional<path> find_file(const path& dir_path, const path& file_name) {
+static boost::optional<path> find_file(const path &dir_path, const path &file_name) {
 	const recursive_directory_iterator end;
 	const auto it = find_if(recursive_directory_iterator(dir_path), end,
-		[&file_name](const directory_entry& e) {
-			return e.path().filename() == file_name;
-		});
+							[&file_name](const directory_entry &e) { return e.path().filename() == file_name; });
 	return it == end ? boost::optional<path>() : it->path();
 }
-
 
 /*****************************************************************************
  * Application Folder tests
  *****************************************************************************/
-BOOST_AUTO_TEST_CASE( read_license_near_module ) {
+BOOST_AUTO_TEST_CASE(read_license_near_module) {
 	const string testExeFolder = PROJECT_BINARY_DIR "/test/library";
 	bool exeFileFound = false;
 	string referenceExeFileName;
 	string referenceLicenseFileName;
-	//Verify we're pointing the correct executable, in windows isn't clear where it's built
+	// Verify we're pointing the correct executable, in windows isn't clear where it's built
 #ifdef _WIN32
 	boost::optional<path> exeLocation(find_file(path(testExeFolder), path(BOOST_TEST_MODULE ".exe")));
 	exeFileFound = exeLocation.has_value();
 	if (exeFileFound) {
 		referenceExeFileName = exeLocation.get().string();
-		referenceLicenseFileName = referenceExeFileName.replace(referenceExeFileName.find(BOOST_TEST_MODULE ".exe"),
-			string(BOOST_TEST_MODULE ".exe").size(), BOOST_TEST_MODULE ".lic");
+		referenceLicenseFileName =
+			referenceExeFileName.replace(referenceExeFileName.find(BOOST_TEST_MODULE ".exe"),
+										 string(BOOST_TEST_MODULE ".exe").size(), BOOST_TEST_MODULE ".lic");
 	}
 #else
 	referenceExeFileName = testExeFolder + "/" + BOOST_TEST_MODULE;
@@ -62,7 +60,7 @@
 #endif
 	BOOST_WARN_MESSAGE(!exeFileFound, "File [" + referenceExeFileName + "] NOT found");
 	if (exeFileFound) {
-		//copy test license near module
+		// copy test license near module
 		std::ifstream src(MOCK_LICENSE, std::ios::binary);
 		std::ofstream dst(referenceLicenseFileName, std::ios::binary);
 		dst << src.rdbuf();
@@ -74,15 +72,12 @@
 		BOOST_CHECK(registry.isGood());
 		BOOST_REQUIRE_EQUAL(1, licenseInfos.size());
 		string currentLocation = licenseInfos[0];
-		BOOST_CHECK_MESSAGE(equivalent(path(referenceLicenseFileName),path(currentLocation)),
-			"file " +currentLocation + "found at expected location");
-		string licenseRealContent = applicationFolder.retrieve_license_content(
-			currentLocation);
+		BOOST_CHECK_MESSAGE(equivalent(path(referenceLicenseFileName), path(currentLocation)),
+							"file " + currentLocation + "found at expected location");
+		string licenseRealContent = applicationFolder.retrieve_license_content(currentLocation);
 		src.seekg(0, ios::beg);
-		std::string referenceContent((std::istreambuf_iterator<char>(src)),
-			std::istreambuf_iterator<char>());
-		BOOST_CHECK_MESSAGE(referenceContent.compare(licenseRealContent) == 0,
-			"File content is same");
+		std::string referenceContent((std::istreambuf_iterator<char>(src)), std::istreambuf_iterator<char>());
+		BOOST_CHECK_MESSAGE(referenceContent.compare(licenseRealContent) == 0, "File content is same");
 		remove(referenceLicenseFileName.c_str());
 	}
 }
@@ -91,126 +86,101 @@
  * External_Definition tests
  *****************************************************************************/
 
-BOOST_AUTO_TEST_CASE( external_definition ) {
-	//an application can define multiple license locations separated by ';'
-	const char *applicationDefinedString =
-	MOCK_LICENSE ";/this/one/doesnt/exist";
+BOOST_AUTO_TEST_CASE(external_definition) {
+	// an application can define multiple license locations separated by ';'
+	const char *applicationDefinedString = MOCK_LICENSE ";/this/one/doesnt/exist";
 
-	//read test license
+	// read test license
 	std::ifstream src(MOCK_LICENSE, std::ios::binary);
-	std::string referenceContent((std::istreambuf_iterator<char>(src)),
-			std::istreambuf_iterator<char>());
+	std::string referenceContent((std::istreambuf_iterator<char>(src)), std::istreambuf_iterator<char>());
 	license::EventRegistry registry;
-	const LicenseLocation licLocation={applicationDefinedString,nullptr};
+	const LicenseLocation licLocation = {applicationDefinedString, nullptr};
 	ExternalDefinition externalDefinition(&licLocation);
 	vector<string> licenseInfos = externalDefinition.license_locations(registry);
 	BOOST_CHECK(registry.isGood());
 	BOOST_CHECK_EQUAL(1, licenseInfos.size());
 	string currentLocation = licenseInfos[0];
-	BOOST_CHECK_MESSAGE(string(MOCK_LICENSE).compare(currentLocation) == 0,
-			"file found at expected location");
-	string licenseRealContent = externalDefinition.retrieve_license_content(
-			currentLocation);
-	BOOST_CHECK_MESSAGE(referenceContent.compare(licenseRealContent) == 0,
-			"File content is same");
+	BOOST_CHECK_MESSAGE(string(MOCK_LICENSE).compare(currentLocation) == 0, "file found at expected location");
+	string licenseRealContent = externalDefinition.retrieve_license_content(currentLocation);
+	BOOST_CHECK_MESSAGE(referenceContent.compare(licenseRealContent) == 0, "File content is same");
 }
 
 /**
  * The license file doesn't exist. Check that the locator reports the right error
  */
-BOOST_AUTO_TEST_CASE( external_definition_not_found ) {
+BOOST_AUTO_TEST_CASE(external_definition_not_found) {
 	const char *applicationDefinedString = PROJECT_TEST_SRC_DIR "/this/file/doesnt/exist";
 	license::EventRegistry registry;
-	const LicenseLocation licLocation = { applicationDefinedString,nullptr };
+	const LicenseLocation licLocation = {applicationDefinedString, nullptr};
 	ExternalDefinition externalDefinition(&licLocation);
 	vector<string> licenseInfos = externalDefinition.license_locations(registry);
 
-	BOOST_CHECK_MESSAGE(registry.isGood(),
-			"No fatal error for now, only warnings");
+	BOOST_CHECK_MESSAGE(registry.isGood(), "No fatal error for now, only warnings");
 	registry.turnWarningsIntoErrors();
 	BOOST_REQUIRE_MESSAGE(!registry.isGood(), "Error detected");
 	BOOST_CHECK_EQUAL(0, licenseInfos.size());
-	BOOST_CHECK_MESSAGE(
-			registry.getLastFailure()->event_type == LICENSE_FILE_NOT_FOUND,
-			"Error detected");
-
+	BOOST_CHECK_MESSAGE(registry.getLastFailure()->event_type == LICENSE_FILE_NOT_FOUND, "Error detected");
 }
 
 /*****************************************************************************
  * EnvironmentVarLocation tests
  *****************************************************************************/
-BOOST_AUTO_TEST_CASE( environment_var_location ) {
-	//an application can define multiple license locations separated by ';'
-	const char *environment_variable_value =
-	MOCK_LICENSE ";/this/one/doesnt/exist";
+BOOST_AUTO_TEST_CASE(environment_var_location) {
+	// an application can define multiple license locations separated by ';'
+	const char *environment_variable_value = MOCK_LICENSE ";/this/one/doesnt/exist";
 #ifdef _WIN32
 	_putenv_s(LICENSE_LOCATION_ENV_VAR, environment_variable_value);
 #else
 	setenv(LICENSE_LOCATION_ENV_VAR, environment_variable_value, 1);
 #endif
-	//read test license
+	// read test license
 	std::ifstream src(MOCK_LICENSE, std::ios::binary);
-	std::string referenceContent((std::istreambuf_iterator<char>(src)),
-			std::istreambuf_iterator<char>());
+	std::string referenceContent((std::istreambuf_iterator<char>(src)), std::istreambuf_iterator<char>());
 	license::EventRegistry registry;
 
 	EnvironmentVarLocation envVarLocationStrategy;
-	vector<string> licenseInfos = envVarLocationStrategy.license_locations(
-			registry);
+	vector<string> licenseInfos = envVarLocationStrategy.license_locations(registry);
 	BOOST_CHECK(registry.isGood());
 	BOOST_CHECK_EQUAL(1, licenseInfos.size());
 	string currentLocation = licenseInfos[0];
-	BOOST_CHECK_MESSAGE(string(MOCK_LICENSE).compare(currentLocation) == 0,
-			"file found at expected location");
-	string licenseRealContent = envVarLocationStrategy.retrieve_license_content(
-			currentLocation);
-	BOOST_CHECK_MESSAGE(referenceContent.compare(licenseRealContent) == 0,
-			"File content is same");
+	BOOST_CHECK_MESSAGE(string(MOCK_LICENSE).compare(currentLocation) == 0, "file found at expected location");
+	string licenseRealContent = envVarLocationStrategy.retrieve_license_content(currentLocation);
+	BOOST_CHECK_MESSAGE(referenceContent.compare(licenseRealContent) == 0, "File content is same");
 	UNSETENV(LICENSE_LOCATION_ENV_VAR);
 }
 
 /**
  * The license file doesn't exist. Check that the locator reports the right error
  */
-BOOST_AUTO_TEST_CASE( environment_var_location_not_found ) {
-	const char *environment_variable_value =
-	PROJECT_TEST_SRC_DIR "/this/file/doesnt/exist";
-    SETENV(LICENSE_LOCATION_ENV_VAR, environment_variable_value);
+BOOST_AUTO_TEST_CASE(environment_var_location_not_found) {
+	const char *environment_variable_value = PROJECT_TEST_SRC_DIR "/this/file/doesnt/exist";
+	SETENV(LICENSE_LOCATION_ENV_VAR, environment_variable_value);
 
 	license::EventRegistry registry;
 	EnvironmentVarLocation envVarLocationStrategy;
-	vector<string> licenseInfos = envVarLocationStrategy.license_locations(
-			registry);
-	BOOST_CHECK_MESSAGE(registry.isGood(),
-			"No fatal error for now, only warnings");
+	vector<string> licenseInfos = envVarLocationStrategy.license_locations(registry);
+	BOOST_CHECK_MESSAGE(registry.isGood(), "No fatal error for now, only warnings");
 	registry.turnWarningsIntoErrors();
 	BOOST_REQUIRE_MESSAGE(!registry.isGood(), "Error detected");
 	BOOST_CHECK_EQUAL(0, licenseInfos.size());
-	BOOST_CHECK_MESSAGE(
-			registry.getLastFailure()->event_type == LICENSE_FILE_NOT_FOUND,
-			"Error detected");
+	BOOST_CHECK_MESSAGE(registry.getLastFailure()->event_type == LICENSE_FILE_NOT_FOUND, "Error detected");
 	UNSETENV(LICENSE_LOCATION_ENV_VAR);
 }
 
 /**
  * The license file doesn't exist. Check that the locator reports the right error
  */
-BOOST_AUTO_TEST_CASE( environment_var_location_not_defined ) {
+BOOST_AUTO_TEST_CASE(environment_var_location_not_defined) {
 	UNSETENV(LICENSE_LOCATION_ENV_VAR);
 	license::EventRegistry registry;
 	EnvironmentVarLocation environmentVarLocation;
-	vector<string> licenseInfos = environmentVarLocation.license_locations(
-			registry);
+	vector<string> licenseInfos = environmentVarLocation.license_locations(registry);
 
-	BOOST_CHECK_MESSAGE(registry.isGood(),
-			"No fatal error for now, only warnings");
+	BOOST_CHECK_MESSAGE(registry.isGood(), "No fatal error for now, only warnings");
 	registry.turnWarningsIntoErrors();
 	BOOST_REQUIRE_MESSAGE(!registry.isGood(), "Error detected");
 	BOOST_CHECK_EQUAL(0, licenseInfos.size());
-	BOOST_CHECK_MESSAGE(
-			registry.getLastFailure()->event_type
-					== ENVIRONMENT_VARIABLE_NOT_DEFINED, "Error detected");
-
+	BOOST_CHECK_MESSAGE(registry.getLastFailure()->event_type == ENVIRONMENT_VARIABLE_NOT_DEFINED, "Error detected");
 }
 
-}  //namespace test
+}  // namespace test
diff --git a/test/library/LicenseReader_test.cpp b/test/library/LicenseReader_test.cpp
index e0d32aa..0b16149 100644
--- a/test/library/LicenseReader_test.cpp
+++ b/test/library/LicenseReader_test.cpp
@@ -11,13 +11,15 @@
 
 #include "../../src/library/base/EventRegistry.h"
 #include "../../src/library/os/os.h"
+#include "../../src/library/locate/LocatorFactory.hpp"
 #include "../../src/library/LicenseReader.hpp"
-
+namespace license {
 namespace test {
+
 using namespace license;
 using namespace std;
 /**
- * Read license at fixed location
+ * Read license at application provided location
  */
 BOOST_AUTO_TEST_CASE(read_single_file) {
 	const char *licLocation = PROJECT_TEST_SRC_DIR "/library/test_reader.ini";
@@ -50,7 +52,9 @@
  */
 BOOST_AUTO_TEST_CASE(file_not_found) {
 	const char *licLocation = PROJECT_TEST_SRC_DIR "/library/not_found.ini";
-	// const char * envName = "MYVAR";
+
+	locate::LocatorFactory::find_license_near_module(false);
+	locate::LocatorFactory::find_license_with_env_var(false);
 	const LicenseLocation location = {licLocation, nullptr};
 	LicenseReader licenseReader(&location);
 	vector<FullLicenseInfo> licenseInfos;
@@ -67,14 +71,15 @@
 BOOST_AUTO_TEST_CASE(env_var_not_defined) {
 	UNSETENV(LICENSE_LOCATION_ENV_VAR);
 	const LicenseLocation location = {nullptr, nullptr};
+	locate::LocatorFactory::find_license_near_module(false);
+	locate::LocatorFactory::find_license_with_env_var(true);
 	LicenseReader licenseReader(&location);
 	vector<FullLicenseInfo> licenseInfos;
 	const EventRegistry registry = licenseReader.readLicenses("PRODUCT", licenseInfos);
 	BOOST_CHECK(!registry.isGood());
 	BOOST_CHECK_EQUAL(0, licenseInfos.size());
 	BOOST_ASSERT(registry.getLastFailure() != NULL);
-	BOOST_CHECK_MESSAGE((ENVIRONMENT_VARIABLE_NOT_DEFINED == registry.getLastFailure()->event_type) ||
-							(LICENSE_FILE_NOT_FOUND == registry.getLastFailure()->event_type),
+	BOOST_CHECK_MESSAGE((ENVIRONMENT_VARIABLE_NOT_DEFINED == registry.getLastFailure()->event_type),
 						"error as expected");
 }
 
@@ -85,6 +90,8 @@
 BOOST_AUTO_TEST_CASE(env_var_point_to_wrong_file) {
 	const char *environment_variable_value = PROJECT_TEST_SRC_DIR "/this/file/doesnt/exist";
 	SETENV(LICENSE_LOCATION_ENV_VAR, environment_variable_value)
+	locate::LocatorFactory::find_license_near_module(false);
+	locate::LocatorFactory::find_license_with_env_var(true);
 
 	const LicenseLocation location = {nullptr, nullptr};
 	LicenseReader licenseReader(&location);
@@ -97,4 +104,5 @@
 	BOOST_CHECK_EQUAL(LICENSE_FILE_NOT_FOUND, registry.getLastFailure()->event_type);
 	UNSETENV(LICENSE_LOCATION_ENV_VAR);
 }
-} /* namespace test*/
+}  // namespace test
+}  // namespace license

--
Gitblit v1.9.1