Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dc754df
Removes VK and Yandex OAuth2 authorization.
RomanKotovych Aug 17, 2024
9a0ecdf
Add integration tests with Testcontainers
RomanKotovych Aug 21, 2024
d6b2b5e
Removes unused imports
RomanKotovych Aug 21, 2024
bfe08bf
Removes testcontainers annotation from class without testcontainers
RomanKotovych Aug 21, 2024
a9b7f98
Refactors file upload to use Java NIO.
RomanKotovych Aug 21, 2024
87b7cd4
Moves sensitive data to sensitive.yaml
RomanKotovych Aug 21, 2024
633aa9e
Add tag management endpoints
RomanKotovych Aug 21, 2024
a6fe4b1
Add localization
RomanKotovych Aug 26, 2024
fece9e5
Add Russian localization
RomanKotovych Aug 26, 2024
028fa55
added and configured Dockerfile
RomanKotovych Aug 27, 2024
d275dfb
Add docker-compose.yml, changed nginx configuration and Dockerfile
RomanKotovych Aug 28, 2024
d2734f1
Update README.md
RomanKotovych Aug 28, 2024
2a79680
Add ProfileRestController tests
RomanKotovych Aug 28, 2024
62b2185
Fix not creating account
RomanKotovych Aug 29, 2024
7593f61
Remove language changing menu in mails
RomanKotovych Aug 30, 2024
8222bc1
Added task time tracking
RomanKotovych Sep 3, 2024
9dbd1a7
Refactor: Simplify calculateTimeBetweenStatuses method (master)
RomanKotovych Sep 3, 2024
df6a7b5
Revert "Refactor: Simplify calculateTimeBetweenStatuses method (master)"
RomanKotovych Sep 3, 2024
9708fd9
fix not working calculateTimeBetweenStatuses method
RomanKotovych Sep 3, 2024
73783f8
first attempt of adding jwt
RomanKotovych Sep 4, 2024
9048be6
Fix not working JWT generation
RomanKotovych Sep 4, 2024
c458700
Still not working jwt
RomanKotovych Sep 6, 2024
8643fa7
removed useless variables and fixed not working app
RomanKotovych Sep 6, 2024
8d85816
Add WORKING(!!!!!!!!!!!!) authorization with jwt
RomanKotovych Sep 8, 2024
6466807
add authorization header to requests(not working authorities yet)
RomanKotovych Sep 8, 2024
173f0f5
Revert "add authorization header to requests(not working authorities …
RomanKotovych Sep 8, 2024
dc7a970
Add jwt token header to every request
RomanKotovych Sep 8, 2024
caa71d8
fixed not working api calls
RomanKotovych Sep 8, 2024
4069d41
Update README.md
RomanKotovych Sep 8, 2024
18374b4
Fix not working js script
RomanKotovych Sep 8, 2024
104c0dc
Add droid language and language change in profile
RomanKotovych Sep 9, 2024
452a94a
fix tests
RomanKotovych Sep 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM maven:3.8.5-openjdk-17 AS build
COPY src /app/src
COPY pom.xml /app
COPY resources /resources
RUN mvn -f /app/pom.xml clean package -Pprod
RUN rm -rf /app/src
EXPOSE 8080
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-jar","/app/target/jira-1.0.jar"]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@
- https://habr.com/ru/articles/259055/

Список выполненных задач:

1. Удалить социальные сети: vk, yandex
2. Testcontainers
3. Cделать рефакторинг метода com.javarush.jira.bugtracking.attachment.FileUtil#upload
4. Вынести чувствительную информацию в отдельный проперти файл
5. Добавить новый функционал: добавления тегов к задаче (REST API + реализация на сервисе)
6. Добавить локализацию
7. Написать Dockerfile
8. Написать docker-compose файл для запуска контейнера сервера вместе с БД и nginx.
9. Написать тесты для всех публичных методов контроллера ProfileRestController
10. Добавить подсчет времени сколько задача находилась в работе и тестировании
11. JWT
...
2 changes: 1 addition & 1 deletion config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ server {
gzip_min_length 2048;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root /opt/jirarush/resources;
root /resources;

if ($request_uri ~ ';') {return 404;}

Expand Down
4 changes: 4 additions & 0 deletions docker-compose.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PROD_DATASOURCE_URL=jdbc:postgresql://db:5432/jira
PROD_DATASOURCE_USERNAME=jira
PROD_DATASOURCE_PASSWORD=JiraRush
PROD_HOST_PORT=8080
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3.8"

services:
app:
container_name: app
build:
context: .
dockerfile: Dockerfile
restart: always
env_file: ./docker-compose.env
ports:
- "8080:8080"
depends_on:
- db
- nginx


db:
container_name: db
image: postgres:latest
restart: always
environment:
POSTGRES_USER: jira
POSTGRES_PASSWORD: JiraRush
ports:
- "5432:5432"
volumes:
- ./data/db:/var/lib/postgresql/data/


nginx:
container_name: nginx
image: nginx:latest
restart: always
ports:
- "80:80"
volumes:
- ./config/nginx.conf:/etc/nginx/conf.d/nginx.conf


49 changes: 49 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<name>JiraRush</name>
<description>Mini-JIRA from JavaRush</description>


<properties>
<java.version>17</java.version>
<springdoc.version>2.0.2</springdoc.version>
Expand All @@ -23,7 +24,36 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.20.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.5</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down Expand Up @@ -88,6 +118,24 @@
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
Expand Down Expand Up @@ -144,6 +192,7 @@
</dependency>
</dependencies>


<build>
<plugins>
<plugin>
Expand Down
10 changes: 5 additions & 5 deletions resources/mails/email-confirmation.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html th:lang="${#locale}" lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>JiraRush - подтверждение почты</title>
<title th:text="#{mails.confirmation.title}">JiraRush - подтверждение почты</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
</head>
<body>
<p th:text="'Привет, ' + ${user.firstName} + '.'"/>
<p>Чтобы завершить настройку учетной записи и начать пользоваться JiraRush, подтвердите, что вы правильно указали вашу
<p th:text="#{hello} + ', ' + ${user.firstName} + '.'"/>
<p th:text="#{mails.confirmation.text}">Чтобы завершить настройку учетной записи и начать пользоваться JiraRush, подтвердите, что вы правильно указали вашу
электронную почту.</p>
<a th:href="${confirmationUrl}">Подтвердить почту</a>
<a th:text="#{mails.confirmation.confirm_mail}" th:href="${confirmationUrl}">Подтвердить почту</a>
</body>
</html>
8 changes: 4 additions & 4 deletions resources/mails/password-reset.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head">
<title>JiraRush - установить новый пароль</title>
<title th:text="#{mails.password_reset.title}">JiraRush - установить новый пароль</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
</head>
<body>
<p th:text="'Привет, ' + ${user.firstName} + '.'"/>
<p th:text="'Мы получили запрос на установку нового пароля JiraRush для учетной записи: ' + ${user.email} + '.'"/>
<a th:href="${resetUrl}">Установить пароль</a>
<p th:text="#{hello} + ',' + ${user.firstName} + '.'"/>
<p th:text="#{mails.password_reset.text}' + ${user.email} + '.'"/>
<a th:text="#{mails.password_reset.set_password}" th:href="${resetUrl}">Установить пароль</a>
</body>
</html>
2 changes: 2 additions & 0 deletions resources/static/js/attachments.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$.ajaxSetup({headers: {"Authorization": "Bearer " + localStorage.getItem("token")}});

function deleteAtt(attId) {
$.ajax({
url: '/api/attachments/' + attId,
Expand Down
2 changes: 1 addition & 1 deletion resources/static/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function makeEditable(datatableOpts) {
});

// solve problem with cache in IE: https://stackoverflow.com/a/4303862/548473
$.ajaxSetup({cache: false});
$.ajaxSetup({cache: false, headers: {"Authorization": "Bearer " + localStorage.getItem("token")}});
}

function add() {
Expand Down
2 changes: 2 additions & 0 deletions resources/static/js/contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ let menuItemsPopulated;
let populateContextMenuFunction;
let onMenuCloseFunction;

$.ajaxSetup({headers: {"Authorization": "Bearer " + localStorage.getItem("token")}});

function setupContextMenu(elementClass, populateFunction, onCloseFunction) {
populateContextMenuFunction = populateFunction;
onMenuCloseFunction = onCloseFunction;
Expand Down
2 changes: 2 additions & 0 deletions resources/static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const doneTaskColumn = $('#done-task-column');
const tasksByColumns = new Map();
const oneDayMillis = 1000 * 60 * 60 * 24;

$.ajaxSetup({headers: {"Authorization": "Bearer " + localStorage.getItem("token")}});

$(window).on('load', () => init());

function init() {
Expand Down
2 changes: 2 additions & 0 deletions resources/static/js/profile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const codeTitleMap = new Map();

$.ajaxSetup({headers: {"Authorization": "Bearer " + localStorage.getItem("token")}});

function changeInputContactCodeToTitleAndReturnCode(row) {
let typeCode = row.cells[0].children[0].value;
const typeTitle = codeTitleMap.get(typeCode);
Expand Down
2 changes: 2 additions & 0 deletions resources/static/js/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ let selectReftype = document.getElementById('select-reftype');
let modalRef = document.getElementById('modalRef');
let modalCaller = '';

$.ajaxSetup({headers: {"Authorization": "Bearer " + localStorage.getItem("token")}});

getRefsByType(selectReftype.value);
selectReftype.addEventListener('change', () => {
let refType = selectReftype.value;
Expand Down
2 changes: 2 additions & 0 deletions resources/static/js/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const taskTotalRow = $('#task-total-row');
let sprintList = [];
const oneDayMillis = 1000 * 60 * 60 * 24;

$.ajaxSetup({headers: {"Authorization": "Bearer " + localStorage.getItem("token")}});

$(window).on('load', () => init());

function init() {
Expand Down
2 changes: 2 additions & 0 deletions resources/static/js/tree.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$.ajaxSetup({headers: {"Authorization": "Bearer " + localStorage.getItem("token")}});

$(function () {
setupContextMenu('fancytree-node',
((node) => {
Expand Down
2 changes: 2 additions & 0 deletions resources/static/js/users.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const userUrl = "/api/admin/users";

$.ajaxSetup({headers: {"Authorization": "Bearer " + localStorage.getItem("token")}});

// https://stackoverflow.com/a/5064235/548473
const ctx = {
ajaxUrl: userUrl,
Expand Down
2 changes: 1 addition & 1 deletion resources/view/404.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<html lang="ru">
<html th:lang="${#locale}" lang="ru">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
<meta content="width=device-width, initial-scale=1" name="viewport">
Expand Down
2 changes: 1 addition & 1 deletion resources/view/admin/users.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="ru" xmlns:th="http://www.thymeleaf.org">
<html th:lang="${#locale}" lang="ru" xmlns:th="http://www.thymeleaf.org">
<th:block th:replace="~{layout/main::page(title='Users',appMain=~{::appMain}, activeMenuItem='users')}">
<appMain>
<div class="jumbotron pt-4">
Expand Down
2 changes: 1 addition & 1 deletion resources/view/dashboard.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="ru" xmlns:th="http://www.thymeleaf.org">
<html th:lang="${#locale}" lang="ru" xmlns:th="http://www.thymeleaf.org">

<th:block
th:replace="~{layout/main::page(title='JiraRush: mini bugtracking system',appMainFluid=~{::appMain}, activeMenuItem='dashboard')}">
Expand Down
2 changes: 1 addition & 1 deletion resources/view/exception.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<html lang="ru" xmlns:th="http://www.thymeleaf.org">
<html th:lang="${#locale}" lang="ru" xmlns:th="http://www.thymeleaf.org">
<th:block th:replace="~{layout/main::page(title='Application Error',appMain=~{::appMain})}">
<appMain>
<div class="text-center">
Expand Down
19 changes: 15 additions & 4 deletions resources/view/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<!DOCTYPE html>
<html lang="ru" xmlns:th="http://www.thymeleaf.org">
<html th:lang="${#locale}" lang="en" xmlns:th="http://www.thymeleaf.org">
<!--/*@thymesVar id="authUser" type="com.javarush.jira.login.AuthUser"*/-->

<th:block th:replace="~{layout/main::page(title='JiraRush: mini bugtracking system',appMain=~{::appMain})}">
<appMain>
<h1>JiraRush Home page</h1>
<div th:insert="layout/lang :: menu"></div>
<h1 th:text="#{home.text}">JiraRush Home page</h1>
<div th:if="${authUser} != null">
<form action="/ui/logout" method="post">
<button class="btn btn-primary btn-lg mt-3" type="submit">Logout</button>
<button th:text="#{button.logout}" class="btn btn-primary btn-lg mt-3" type="submit">Logout</button>
</form>
</div>
<th:block th:if="${jwt}">
<script th:inline="javascript">
(function() {
let token = /*[[${jwt}]]*/ null;
if (token) {
localStorage.setItem("token", token);
window.location.href = "/";
}
})();
</script>
</th:block>
</appMain>
</th:block>
2 changes: 1 addition & 1 deletion resources/view/layout/bugtrackLayout.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<!-- view/edit layouts for Task, Sprint, Project -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html th:lang="${#locale}" lang="en" xmlns:th="http://www.thymeleaf.org">
<!--/*@thymesVar id="codeTo" type="com.javarush.jira.common.to.CodeTo"*/-->
<!--/*@thymesVar id="attachs" type="java.util.List<com.javarush.jira.bugtracking.attachment.Attachment>"*/-->
<!--/*@thymesVar id="belongs" type="java.util.List<com.javarush.jira.bugtracking.UserBelong>"*/-->
Expand Down
Loading