Skip to content

Commit

Permalink
Final changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlistairMRoss committed Sep 28, 2023
1 parent c123120 commit dcb1467
Show file tree
Hide file tree
Showing 107 changed files with 7,735 additions and 184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
@RestController
@RequestMapping("api/accessrequest")
@RequiredArgsConstructor
//@CrossOrigin
public class AccessRequestController {
private final AccessRequestService service;
@PostMapping("/addAr")
Expand All @@ -41,6 +40,7 @@ public AccessRequest updateAccessRequest (@PathVariable("id") int request_id, @R

@PostMapping("/reviewAccess")
public ResponseEntity<String> reviewAccessRequest(@RequestBody ReviewRequest reviewRequest) {
log.info(String.valueOf(reviewRequest));
return service.reviewAccessRequest(reviewRequest);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public class AccessRequest {
private String reason;
private String status;

@ManyToOne(cascade = CascadeType.REMOVE)
@ManyToOne
@JoinColumn(name = "user_id")
private User user_id;

@ManyToOne(cascade = CascadeType.REMOVE)
@ManyToOne
@JoinColumn(name = "data_scope_id")
private DataScope data_scope_id;
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public AccessRequest updateAccessRequest(AccessRequest accessRequest) {
}

public ResponseEntity<String> reviewAccessRequest(ReviewRequest reviewRequest) {
log.info(String.valueOf(reviewRequest));
log.info(String.valueOf(reviewRequest.isReview()));
if (reviewRequest.isReview()) {
Optional<DataScope> dataScopeOptional = dataScopeRepository.findByDataScopeId(reviewRequest.getDataScope_id());
Optional<User> userOptional = userRepository.findByEmail(reviewRequest.getUser_email());
Expand All @@ -78,15 +80,21 @@ public ResponseEntity<String> reviewAccessRequest(ReviewRequest reviewRequest) {
} else {
deleteService.deleteAccessRequestAndSaveToSecondary(reviewRequest.getRequest_id());
emailUser(reviewRequest.getUser_email(), "", "Denied");
return ResponseEntity.ok("rejected access");
String message = "rejected access";
return ResponseEntity.ok(message);
}
return ResponseEntity.badRequest().build();
}

private void emailUser(String email, String ds_name, String status){
String subject = "Access Request response";
String body = "Your request to access the Datascope: " + ds_name + "was " + status;
emailService.sendEmail(email, subject, body);
try{
String subject = "Access Request response";
String body = "Your request to access the Datascope: " + ds_name + "was " + status;
emailService.sendEmail(email, subject, body);
} catch (Exception e){
throw (e);
}

}

public Long getTotalAccessRequests() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ public Long getMyTotalAssetRequests(User user) {
return assetRequestRepository.countAssetRequestsByUser(user);
}

private void emailUser(String email, String asset_name, String status){
String subject = "Asset Request response";
String body = "Your request to get an asset \n" + asset_name + "\nwas " + status;
emailService.sendEmail(email, subject, body);
private void emailUser(String email, String asset_name, String status) {
try {
String subject = "Asset Request response";
String body = "Your request to get an asset \n" + asset_name + "\nwas " + status;
emailService.sendEmail(email, subject, body);
} catch (Exception e) {
throw (e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import com.fragile.infosafe.primary.model.*;
import com.fragile.infosafe.primary.repository.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
@RequiredArgsConstructor
@Slf4j
public class DeleteService {

private final UserRepository userRepository;
Expand All @@ -36,6 +38,7 @@ public class DeleteService {
public void deleteUserAndSaveToSecondary(String email) {
Optional<User> entityOptional = userRepository.findByEmail(email);
if (entityOptional.isPresent()) {
log.info("Deleting user");
User entityToDelete = entityOptional.get();
DeletedUser de = new DeletedUser();
de.setEmail(entityToDelete.getEmail());
Expand All @@ -51,6 +54,7 @@ public void deleteUserAndSaveToSecondary(String email) {
public void deleteDataScopeAndSaveToSecondary(int datascope_id) {
Optional<DataScope> entityOptional = dataScopeRepository.findByDataScopeId(datascope_id);
if(entityOptional.isPresent()) {
log.info("Deleting datascope");
DataScope entityToDelete = entityOptional.get();
DeletedDataScope de = new DeletedDataScope();
de.setDs_name(entityToDelete.getDs_name());
Expand All @@ -66,6 +70,7 @@ public void deleteDataScopeAndSaveToSecondary(int datascope_id) {
public void deleteAssetAndSaveToSecondary(int asset_id) {
Optional<Asset> entityOptional = assetRepository.findByAssetId(asset_id);
if(entityOptional.isPresent()) {
log.info("Deleting Asset");
Asset entityToDelete = entityOptional.get();
DeletedAsset de = new DeletedAsset();
de.setAsset_description(entityToDelete.getAsset_description());
Expand All @@ -84,6 +89,7 @@ public void deleteAssetAndSaveToSecondary(int asset_id) {
public void deleteTaskAndSaveToSecondary(int task_id, String completion) {
Optional<Task> entityOptional = taskRepository.findByTaskId(task_id);
if(entityOptional.isPresent()){
log.info("Deleting task");
Task entityToDelete = entityOptional.get();
DeletedTask de = new DeletedTask();
de.setTask_status(entityToDelete.getTask_status());
Expand All @@ -94,11 +100,13 @@ public void deleteTaskAndSaveToSecondary(int task_id, String completion) {
deletedTaskRepository.save(de);
taskRepository.delete(entityToDelete);
}

}

public void deleteAccessRequestAndSaveToSecondary(int request_id){
Optional<AccessRequest> entityOptional = accessRequestRepository.findById(request_id);
if(entityOptional.isPresent()){
log.info("Deleting AccessRequest");
AccessRequest entityToDelete = entityOptional.get();
DeletedAccessRequest de = new DeletedAccessRequest();
de.setReason(entityToDelete.getReason());
Expand Down Expand Up @@ -137,7 +145,10 @@ public void deleteSupportRequestAndSaveToSecondary(int request_id){

public void deleteAssetRequestAndSaveToSecondary(int request_id){
Optional<AssetRequests> entityOptional = assetRequestRepository.findById(request_id);
log.info(String.valueOf(entityOptional.isPresent()));
log.info(String.valueOf(entityOptional.get()));
if(entityOptional.isPresent()){
log.info("Deleting AssetRequest");
AssetRequests entityToDelete = entityOptional.get();
DeletedAssetRequest de = new DeletedAssetRequest();
de.setAsset_id(entityToDelete.getAsset().getAsset_id());
Expand All @@ -153,6 +164,7 @@ public void deleteAssetRequestAndSaveToSecondary(int request_id){
public boolean deleteRiskAndSaveToSecondary(int risk_id) {
Optional<Risk> entityOptional = riskRepository.findRiskByRiskId(risk_id);
if(entityOptional.isPresent()){
log.info("Deleting Risk");
Risk entityToDelete = entityOptional.get();
var de = DeletedRisk.builder()
.risk_name(entityToDelete.getRisk_name())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ public void deleteOldRecords() {
}

public void makeNotification(String message, User user){
String timeMade = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss"));
Notifications notification = Notifications.builder()
.createdAt(LocalDateTime.now())
.notification(message)
.user(user)
.timeMade(timeMade)
.build();
notificationsRepository.save(notification);
try {
String timeMade = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss"));
Notifications notification = Notifications.builder()
.createdAt(LocalDateTime.now())
.notification(message)
.user(user)
.timeMade(timeMade)
.build();
notificationsRepository.save(notification);
}catch(Exception e){
throw (e);
}
}

public List<Notifications> getNotifications(User user) {
Expand Down
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { defineConfig } = require("cypress");
module.exports = defineConfig({
projectId: "8o48nn",
e2e: {
baseUrl: "http://localhost:8080",
baseUrl: "http://ec2-174-129-77-195.compute-1.amazonaws.com:8080",
viewportWidth: 1024,
viewportHeight: 768,
},
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/e2e.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe("Visits the backend", () => {
it("returns 403 Forbidden", () => {
cy.request({
url: "http://localhost:8080/",
url: "http://ec2-174-129-77-195.compute-1.amazonaws.com:8080/",
failOnStatusCode: false,
}).then((response) => {
expect(response.status).to.equal(403);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@

<!doctype html>
<html lang="en">

<head>
<title>Code coverage report for src/components/About.js</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="../../prettify.css" />
<link rel="stylesheet" href="../../base.css" />
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(../../sort-arrow-sprite.png);
}
</style>
</head>

<body>
<div class='wrapper'>
<div class='pad1'>
<h1><a href="../../index.html">All files</a> / <a href="index.html">src/components</a> About.js</h1>
<div class='clearfix'>

<div class='fl pad1y space-right2'>
<span class="strong">0% </span>
<span class="quiet">Statements</span>
<span class='fraction'>0/2</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>0/0</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">0% </span>
<span class="quiet">Functions</span>
<span class='fraction'>0/1</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">0% </span>
<span class="quiet">Lines</span>
<span class='fraction'>0/2</span>
</div>


</div>
<p class="quiet">
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
</p>
<template id="filterTemplate">
<div class="quiet">
Filter:
<input oninput="onInput()" type="search" id="fileSearch">
</div>
</template>
</div>
<div class='status-line low'></div>
<pre><table class="coverage">
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
<a name='L2'></a><a href='#L2'>2</a>
<a name='L3'></a><a href='#L3'>3</a>
<a name='L4'></a><a href='#L4'>4</a>
<a name='L5'></a><a href='#L5'>5</a>
<a name='L6'></a><a href='#L6'>6</a>
<a name='L7'></a><a href='#L7'>7</a>
<a name='L8'></a><a href='#L8'>8</a>
<a name='L9'></a><a href='#L9'>9</a>
<a name='L10'></a><a href='#L10'>10</a>
<a name='L11'></a><a href='#L11'>11</a>
<a name='L12'></a><a href='#L12'>12</a>
<a name='L13'></a><a href='#L13'>13</a>
<a name='L14'></a><a href='#L14'>14</a>
<a name='L15'></a><a href='#L15'>15</a>
<a name='L16'></a><a href='#L16'>16</a>
<a name='L17'></a><a href='#L17'>17</a>
<a name='L18'></a><a href='#L18'>18</a>
<a name='L19'></a><a href='#L19'>19</a>
<a name='L20'></a><a href='#L20'>20</a>
<a name='L21'></a><a href='#L21'>21</a>
<a name='L22'></a><a href='#L22'>22</a>
<a name='L23'></a><a href='#L23'>23</a>
<a name='L24'></a><a href='#L24'>24</a>
<a name='L25'></a><a href='#L25'>25</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import '../styling/About.css';
import React from 'react';
import {MdOutlineMailOutline} from 'react-icons/md';
&nbsp;
export const About = <span class="cstat-no" title="statement not covered" ><span class="fstat-no" title="function not covered" >()</span> =&gt; {</span>
<span class="cstat-no" title="statement not covered" > return (</span>
&lt;div className="display"&gt;
&lt;div className="aboutBackground"&gt;
&lt;div className="aboutInfo"&gt;
&lt;p className="aboutTitle"&gt;About&lt;/p&gt;
&lt;p className="aboutData"&gt;InfoSafe is an application that is used by the Information Security team, System Administrators, Managers and other employees to automate the data security process. It is a single tool that can be used to monitor and manage any and all operations involving a company’s data and projects within its Information Security Management System (ISMS).
The vision for this project is to create an easy-to-use application with a user-friendly interface where an organization can have access to all their users, data scopes, support related queries/issues, risk reports and tasks.
Users will be assigned certain roles when their profile has been created on the application. These roles are defined by a set of permissions within the application, this is to manage data access as well as to assign administrative rights to certain users.&lt;/p&gt;
&lt;/div&gt;
&lt;div className="contactUsInfo"&gt;
&lt;p className="contactUsTitle"&gt;Contact Us&lt;/p&gt;
&lt;p className="contactUsData"&gt;&lt;MdOutlineMailOutline className="emailIcon"&gt;&lt;/MdOutlineMailOutline&gt; [email protected]&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&nbsp;
&lt;/div&gt;
)
};
&nbsp;
&nbsp;</pre></td></tr></table></pre>

<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2023-09-28T09:53:26.530Z
</div>
<script src="../../prettify.js"></script>
<script>
window.onload = function () {
prettyPrint();
};
</script>
<script src="../../sorter.js"></script>
<script src="../../block-navigation.js"></script>
</body>
</html>

Loading

0 comments on commit dcb1467

Please sign in to comment.