├── files ├── mails │ └── .gitkeep ├── tickets │ ├── NRCyhbIptw.json │ ├── 6xSD9nNjAk.json │ └── 1z9JcEUnW3.json └── users │ └── users.json ├── webpage_preview.png ├── Ticketsystem_User_Manual_DE.pdf ├── ssl ├── server.pub.key ├── server.csr ├── server.cert └── server.key ├── www ├── templates │ ├── footer.html │ ├── navigation.html │ ├── header.html │ ├── login.html │ ├── index.html │ ├── create_ticket.html │ ├── all_tickets.html │ └── dashboard.html └── static │ ├── css │ └── style.css │ └── js │ └── ticketsystem.js ├── util ├── random │ ├── examples_test.go │ ├── random_ids_test.go │ └── random_ids.go ├── jsontools │ ├── examples_test.go │ ├── jsontools.go │ └── jsontools_test.go ├── hashing │ ├── hashing.go │ ├── hashing_test.go │ └── examples_test.go ├── cliutils │ ├── cliutils.go │ ├── examples_test.go │ └── cliutils_test.go └── httptools │ ├── httptools.go │ ├── examples_test.go │ └── httptools_test.go ├── .gitignore ├── globals ├── globals.go └── globals_test.go ├── .codecov.yml ├── structs ├── defaults │ ├── defaults_test.go │ └── defaults.go ├── messages.go ├── structs_test.go └── structs.go ├── startServer.sh ├── startCLI.sh ├── .travis.yml ├── startServer.bat ├── startCLI.bat ├── doc.go ├── api ├── api_in │ └── examples_test.go └── api_out │ └── examples_test.go ├── ticket ├── ticket_test.go └── ticket.go ├── session ├── session.go └── session_test.go ├── cli ├── client │ └── client.go └── io │ └── io.go ├── log └── testlog │ ├── testlog.go │ └── testlog_test.go └── mail_events ├── examples_test.go └── mail_events.go /files/mails/.gitkeep: -------------------------------------------------------------------------------- 1 | # Keep the directory "files/mails" in the Git repository even if it is empty 2 | -------------------------------------------------------------------------------- /webpage_preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mortenterhart/trivial-tickets/HEAD/webpage_preview.png -------------------------------------------------------------------------------- /Ticketsystem_User_Manual_DE.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mortenterhart/trivial-tickets/HEAD/Ticketsystem_User_Manual_DE.pdf -------------------------------------------------------------------------------- /files/tickets/NRCyhbIptw.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "NRCyhbIptw", 3 | "subject": "hello my computer is broken", 4 | "status": 1, 5 | "user": { 6 | "id": "CLwt_Y27ktggbjaNzn5U2fpCM6Az1ktAKo46n0mLP6A=", 7 | "name": "Boris Floricic", 8 | "username": "tron", 9 | "mail": "boris.floricic@example.com", 10 | "hash": "$2a$12$fdohkh9gw4M1GJ5KKgzbwu0btXSPNAT2Y.FPmnTQ.zBCzjvWFGH02", 11 | "isOnHoliday": false 12 | }, 13 | "customer": "helpmepls@mail.de", 14 | "entries": [ 15 | { 16 | "date": "2018-11-12T14:14:51.595674+01:00", 17 | "formattedDate": "Mon Nov 12 14:14:51 2018", 18 | "user": "helpmepls@mail.de", 19 | "text": "computer says no", 20 | "replyType": "external" 21 | } 22 | ], 23 | "mergeTo": "" 24 | } -------------------------------------------------------------------------------- /files/tickets/6xSD9nNjAk.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "6xSD9nNjAk", 3 | "subject": "Test ticket", 4 | "status": 1, 5 | "user": { 6 | "id": "iuxLXN6ACBCZLmKqsDy03wTYRuz3scntN_kvNm_MTZM=", 7 | "name": "Admin", 8 | "username": "admin", 9 | "mail": "admin@trivial-tickets.com", 10 | "hash": "$2a$12$fdohkh9gw4M1GJ5KKgzbwu0btXSPNAT2Y.FPmnTQ.zBCzjvWFGH02", 11 | "isOnHoliday": false 12 | }, 13 | "customer": "customer@gmail.com", 14 | "entries": [ 15 | { 16 | "id": "0001-01-01T00:00:00Z", 17 | "formattedDate": "Thu Nov 29 09:54:47 2018", 18 | "user": "customer@gmail.com", 19 | "text": "This is just a test of creating a ticket. Please ignore this ticket.", 20 | "replyType": "external" 21 | } 22 | ], 23 | "mergeTo": "" 24 | } -------------------------------------------------------------------------------- /ssl/server.pub.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA7/w+qiRxAsIAh3rjJgRQ 3 | 721VSyTBHXm/YfmcjcibsZK3AeNdVX4EZEn8jhYvzJMUh1LSpd+if7RTktEoKg2/ 4 | Lh7L9jKkA2TnMMIjvZXzpUEY+1QbcxlnAlmwnqWNbgTmGdBmefQchZHhxW3+lpAU 5 | DuNbtcSQYLzRgBN1zMWLCpmDL9pslNnpyVuME/J3jJM3UxtwUGJpTi7NJ9Oll+Z+ 6 | /Sfgh+BISPqKpgYj7sKnrqi9zkuAFpVFY6OMb05nvT6ZZ620bTYSSthr+A1+jP6F 7 | uMOIMwRNFmgEejnDUUic/FhQusCcK5Vg9e37RYlNC8Eu5Q7dErKx+71O+hTAAj3j 8 | bDMzjgJsp/vJF5Bb7BK7ARtGLtxFjYscdBmZf5+wzhbRK/lBqV8/AV9CP7V4Wkso 9 | aEwwwFZHeT6EbQuOp2X23ZtAWmtOtlZLcl3ng6MJUxAEBZcWbVKNh3QxCM7fzwBq 10 | P4Dsv16P1KTJKhIZpOsUBBVnXO0co6eorMt4m3CfeFQO/wAAPgIrS6i9ZfWPrH2H 11 | G6AAf+y5i5MQVmBl5HjZBas6FCmH2u6LdyvduaA5dPEh8OdKYVq/4igFEBJzHIJ+ 12 | BJ8v3E1GHqtFTVKeMsDUbBnJA9dRMvuNF9ZZvNfSSmG2f3fmBI3nrghcQju5c0aC 13 | cP+itfa3yLuM4oQNwp27+e0CAwEAAQ== 14 | -----END PUBLIC KEY----- 15 | -------------------------------------------------------------------------------- /files/users/users.json: -------------------------------------------------------------------------------- 1 | { 2 | "admin": { 3 | "id": "iuxLXN6ACBCZLmKqsDy03wTYRuz3scntN_kvNm_MTZM=", 4 | "name": "Admin", 5 | "username": "admin", 6 | "mail": "admin@trivial-tickets.com", 7 | "hash": "$2a$12$fdohkh9gw4M1GJ5KKgzbwu0btXSPNAT2Y.FPmnTQ.zBCzjvWFGH02", 8 | "isOnHoliday": false 9 | }, 10 | "max4711": { 11 | "id": "1lefJPUAZgd58hTuZrN16GbUjDOgCA0xShaUCD2spPY=", 12 | "name": "Max Mustermann", 13 | "username": "max4711", 14 | "mail": "max.mustermann@trivial-tickets.com", 15 | "hash": "$2a$12$fdohkh9gw4M1GJ5KKgzbwu0btXSPNAT2Y.FPmnTQ.zBCzjvWFGH02", 16 | "isOnHoliday": false 17 | }, 18 | "tron": { 19 | "id": "CLwt_Y27ktggbjaNzn5U2fpCM6Az1ktAKo46n0mLP6A=", 20 | "name": "Boris Floricic", 21 | "username": "tron", 22 | "mail": "boris.floricic@trivial-tickets.com", 23 | "hash": "$2a$12$fdohkh9gw4M1GJ5KKgzbwu0btXSPNAT2Y.FPmnTQ.zBCzjvWFGH02", 24 | "isOnHoliday": false 25 | } 26 | } -------------------------------------------------------------------------------- /www/templates/footer.html: -------------------------------------------------------------------------------- 1 | 33 | 34 | {{define "footer"}} 35 | 36 | 37 | 38 | {{end}} 39 | -------------------------------------------------------------------------------- /util/random/examples_test.go: -------------------------------------------------------------------------------- 1 | // Trivial Tickets Ticketsystem 2 | // Copyright (C) 2019 The Contributors 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // Package random implements a pseudo-random algorithm to 18 | // create unique ticket and mail ids. 19 | package random 20 | 21 | import ( 22 | "fmt" 23 | ) 24 | 25 | /* 26 | * Ticketsystem Trivial Tickets 27 | * 28 | * Matriculation numbers: 3040018, 6694964, 3478222 29 | * Lecture: Programmieren II, INF16B 30 | * Lecturer: Herr Prof. Dr. Helmut Neemann 31 | * Institute: Duale Hochschule Baden-Württemberg Mosbach 32 | * 33 | * --------------- 34 | * 35 | * Package random [examples] 36 | * Random id creation 37 | */ 38 | 39 | // Example IDLength demonstrates the expected 40 | // length of a random id for tickets or mails. 41 | func ExampleCreateRandomID_iDLength() { 42 | id := CreateRandomID(10) 43 | 44 | fmt.Println(len(id)) 45 | // Output: 10 46 | } 47 | -------------------------------------------------------------------------------- /www/templates/navigation.html: -------------------------------------------------------------------------------- 1 | 33 | 34 | {{define "navigation"}} 35 | 44 | {{end}} -------------------------------------------------------------------------------- /www/templates/header.html: -------------------------------------------------------------------------------- 1 | 33 | 34 | {{define "header"}} 35 | 36 | 37 | 38 | 39 | 40 | 41 | Trivial Tickets Ticketsystem 42 | 43 | 44 | 45 | 46 | {{end}} -------------------------------------------------------------------------------- /util/jsontools/examples_test.go: -------------------------------------------------------------------------------- 1 | // Trivial Tickets Ticketsystem 2 | // Copyright (C) 2019 The Contributors 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // Package jsontools provides useful tools for encoding JSON 18 | // from a map. 19 | package jsontools 20 | 21 | import "fmt" 22 | 23 | /* 24 | * Ticketsystem Trivial Tickets 25 | * 26 | * Matriculation numbers: 3040018, 6694964, 3478222 27 | * Lecture: Programmieren II, INF16B 28 | * Lecturer: Herr Prof. Dr. Helmut Neemann 29 | * Institute: Duale Hochschule Baden-Württemberg Mosbach 30 | * 31 | * --------------- 32 | * 33 | * Package jsontools [examples] 34 | * Useful tools for encoding JSON 35 | */ 36 | 37 | // Example StatusResponse shows how a HTTP status 38 | // response, e.g. from a web service, is converted 39 | // from a map of properties to a valid JSON string. 40 | func ExampleMapToJSON_statusResponse() { 41 | json := MapToJSON(map[string]interface{}{ 42 | "status": 200, 43 | "message": "OK", 44 | }) 45 | 46 | fmt.Println(string(json)) 47 | // Output: 48 | // { 49 | // "message": "OK", 50 | // "status": 200 51 | // } 52 | } 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Trivial Tickets Ticketsystem 2 | ## Copyright (C) 2019 The Contributors 3 | ## 4 | ## This program is free software: you can redistribute it and/or modify 5 | ## it under the terms of the GNU General Public License as published by 6 | ## the Free Software Foundation, either version 3 of the License, or 7 | ## (at your option) any later version. 8 | ## 9 | ## This program is distributed in the hope that it will be useful, 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ## GNU General Public License for more details. 13 | ## 14 | ## You should have received a copy of the GNU General Public License 15 | ## along with this program. If not, see . 16 | ## 17 | ## 18 | ## Ticketsystem Trivial Tickets 19 | ## 20 | ## Matriculation numbers: 3040018, 6694964, 3478222 21 | ## Lecture: Programmieren II, INF16B 22 | ## Lecturer: Herr Prof. Dr. Helmut Neemann 23 | ## Institute: Duale Hochschule Baden-Württemberg Mosbach 24 | ## 25 | ## --------------- 26 | ## Ignored files in Git 27 | 28 | # Binaries for programs and plugins 29 | *.exe 30 | *.exe~ 31 | *.dll 32 | *.so 33 | *.dylib 34 | 35 | # Server binary in root directory, built with 'go build' 36 | /ticketsystem 37 | 38 | # Test binary, built with `go test -c` 39 | *.test 40 | 41 | # Output of the go coverage tool, specifically when 42 | # used with LiteIDE 43 | *.out 44 | 45 | # Coverage Reports 46 | coverage.txt 47 | 48 | # Jekyll Output 49 | _site 50 | 51 | # Ignore generated mails and tickets 52 | /files/mails/*.json 53 | /files/tickets/*.json 54 | 55 | # Do not ignore predefined tickets 56 | !/files/tickets/1z9JcEUnW3.json 57 | !/files/tickets/6xSD9nNjAk.json 58 | !/files/tickets/NRCyhbIptw.json 59 | 60 | # Ignore IntelliJ files 61 | /.idea 62 | -------------------------------------------------------------------------------- /util/random/random_ids_test.go: -------------------------------------------------------------------------------- 1 | // Trivial Tickets Ticketsystem 2 | // Copyright (C) 2019 The Contributors 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // Package random implements a pseudo-random algorithm to 18 | // create unique ticket and mail ids. 19 | package random 20 | 21 | import ( 22 | "testing" 23 | 24 | "github.com/stretchr/testify/assert" 25 | 26 | "github.com/mortenterhart/trivial-tickets/log/testlog" 27 | "github.com/mortenterhart/trivial-tickets/structs" 28 | ) 29 | 30 | /* 31 | * Ticketsystem Trivial Tickets 32 | * 33 | * Matriculation numbers: 3040018, 6694964, 3478222 34 | * Lecture: Programmieren II, INF16B 35 | * Lecturer: Herr Prof. Dr. Helmut Neemann 36 | * Institute: Duale Hochschule Baden-Württemberg Mosbach 37 | * 38 | * --------------- 39 | * 40 | * Package random [tests] 41 | * Random id creation 42 | */ 43 | 44 | // TestCreateRandomId makes sure the created ticket id is in line with the specification 45 | func TestCreateRandomId(t *testing.T) { 46 | testlog.BeginTest() 47 | defer testlog.EndTest() 48 | 49 | ticketID := CreateRandomID(structs.RandomIDLength) 50 | 51 | assert.True(t, len(ticketID) == structs.RandomIDLength, "Random id has the wrong length") 52 | } 53 | -------------------------------------------------------------------------------- /www/templates/login.html: -------------------------------------------------------------------------------- 1 | 33 | 34 | {{define "login"}} 35 | 49 | {{end}} -------------------------------------------------------------------------------- /www/templates/index.html: -------------------------------------------------------------------------------- 1 | 33 | 34 | {{define "index"}} 35 | {{template "header"}} 36 |
37 |
38 |

Trivial Tickets

39 |
40 | {{template "login" .Session}} 41 |
42 |
43 | {{template "navigation" .Session}} 44 |
45 | {{if .Session.IsLoggedIn}} 46 | {{template "dashboard" .}} 47 | {{template "create_ticket" .Session}} 48 | {{template "all_tickets" .}} 49 | {{else}} 50 | {{template "create_ticket" .Session}} 51 | {{end}} 52 |
53 |
54 | {{template "footer"}} 55 | {{end}} 56 | -------------------------------------------------------------------------------- /util/jsontools/jsontools.go: -------------------------------------------------------------------------------- 1 | // Trivial Tickets Ticketsystem 2 | // Copyright (C) 2019 The Contributors 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // Package jsontools provides useful tools for encoding JSON 18 | // from a map. 19 | package jsontools 20 | 21 | import ( 22 | "encoding/json" 23 | 24 | "github.com/mortenterhart/trivial-tickets/structs" 25 | ) 26 | 27 | /* 28 | * Ticketsystem Trivial Tickets 29 | * 30 | * Matriculation numbers: 3040018, 6694964, 3478222 31 | * Lecture: Programmieren II, INF16B 32 | * Lecturer: Herr Prof. Dr. Helmut Neemann 33 | * Institute: Duale Hochschule Baden-Württemberg Mosbach 34 | * 35 | * --------------- 36 | * 37 | * Package jsontools 38 | * Useful tools for encoding JSON 39 | */ 40 | 41 | // MapToJSON converts a given JSONMap with defined properties 42 | // into a valid JSON string with four spaces of indentation. 43 | func MapToJSON(properties structs.JSONMap) []byte { 44 | // The decoding error of the encoding into JSON is ignored 45 | // here because the json.MarshalIndent() function only returns 46 | // an error if an inconvertible type is given. The given json 47 | // map can be converted by the function and thus it never 48 | // returns an error. 49 | jsonString, _ := json.MarshalIndent(properties, "", " ") 50 | return jsonString 51 | } 52 | -------------------------------------------------------------------------------- /files/tickets/1z9JcEUnW3.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "1z9JcEUnW3", 3 | "subject": "Warning: Cross Site Scripting Attempt", 4 | "status": 1, 5 | "user": { 6 | "id": "1lefJPUAZgd58hTuZrN16GbUjDOgCA0xShaUCD2spPY=", 7 | "name": "Max Mustermann", 8 | "username": "max4711", 9 | "mail": "max.mustermann@trivial-tickets.com", 10 | "hash": "$2a$12$fdohkh9gw4M1GJ5KKgzbwu0btXSPNAT2Y.FPmnTQ.zBCzjvWFGH02", 11 | "isOnHoliday": false 12 | }, 13 | "customer": "customer@gmail.com", 14 | "entries": [ 15 | { 16 | "id": "0001-01-01T00:00:00Z", 17 | "formattedDate": "Thu Nov 29 10:58:28 2018", 18 | "user": "customer@gmail.com", 19 | "text": "I saw a hacker on your site trying to exploit the forms on your website with Cross Site Scripting (XSS).\n\nPlease fix those security issues on your site.", 20 | "replyType": "external" 21 | }, 22 | { 23 | "id": "0001-01-01T00:00:00Z", 24 | "formattedDate": "Thu Nov 29 11:00:44 2018", 25 | "user": "hacker@darknet.com", 26 | "text": "\u0026lt;script\u0026gt;alert(\u0026#39;XSS attack\u0026#39;);\u0026lt;/script\u0026gt;", 27 | "replyType": "external" 28 | }, 29 | { 30 | "id": "0001-01-01T00:00:00Z", 31 | "formattedDate": "Thu Nov 29 11:05:13 2018", 32 | "user": "admin@trivial-tickets.com", 33 | "text": "Dear customer,\n\nThanks for pointing this out. We are currently working hard to fix these circumstances. Please be patient.", 34 | "replyType": "external" 35 | }, 36 | { 37 | "id": "0001-01-01T00:00:00Z", 38 | "formattedDate": "Fri Nov 30 14:31:12 2018", 39 | "user": "admin@trivial-tickets.com", 40 | "text": "We have fixed the security hole. Thank you for this issue.", 41 | "replyType": "external" 42 | } 43 | ], 44 | "mergeTo": "" 45 | } -------------------------------------------------------------------------------- /ssl/server.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIFPzCCAycCAQAwgdkxCzAJBgNVBAYTAkRFMR0wGwYDVQQIDBRCYWRlbi1Xw4PC 3 | vHJ0dGVtYmVyZzEQMA4GA1UEBwwHTW9zYmFjaDE2MDQGA1UECgwtRHVhbGUgSG9j 4 | aHNjaHVsZSBCYWRlbi1Xw4PCvHJ0dGVtYmVyZyBNb3NiYWNoMSIwIAYDVQQLDBlB 5 | cHBsaWVkIENvbXB1dGVyIFNjaWVuY2VzMRIwEAYDVQQDDAlsb2NhbGhvc3QxKTAn 6 | BgkqhkiG9w0BCQEWGmluZm9ybWF0aWtAbW9zYmFjaC5kaGJ3LmRlMIICIjANBgkq 7 | hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA7/w+qiRxAsIAh3rjJgRQ721VSyTBHXm/ 8 | YfmcjcibsZK3AeNdVX4EZEn8jhYvzJMUh1LSpd+if7RTktEoKg2/Lh7L9jKkA2Tn 9 | MMIjvZXzpUEY+1QbcxlnAlmwnqWNbgTmGdBmefQchZHhxW3+lpAUDuNbtcSQYLzR 10 | gBN1zMWLCpmDL9pslNnpyVuME/J3jJM3UxtwUGJpTi7NJ9Oll+Z+/Sfgh+BISPqK 11 | pgYj7sKnrqi9zkuAFpVFY6OMb05nvT6ZZ620bTYSSthr+A1+jP6FuMOIMwRNFmgE 12 | ejnDUUic/FhQusCcK5Vg9e37RYlNC8Eu5Q7dErKx+71O+hTAAj3jbDMzjgJsp/vJ 13 | F5Bb7BK7ARtGLtxFjYscdBmZf5+wzhbRK/lBqV8/AV9CP7V4WksoaEwwwFZHeT6E 14 | bQuOp2X23ZtAWmtOtlZLcl3ng6MJUxAEBZcWbVKNh3QxCM7fzwBqP4Dsv16P1KTJ 15 | KhIZpOsUBBVnXO0co6eorMt4m3CfeFQO/wAAPgIrS6i9ZfWPrH2HG6AAf+y5i5MQ 16 | VmBl5HjZBas6FCmH2u6LdyvduaA5dPEh8OdKYVq/4igFEBJzHIJ+BJ8v3E1GHqtF 17 | TVKeMsDUbBnJA9dRMvuNF9ZZvNfSSmG2f3fmBI3nrghcQju5c0aCcP+itfa3yLuM 18 | 4oQNwp27+e0CAwEAAaAgMB4GCSqGSIb3DQEJBzERDA90cml2aWFsLXRpY2tldHMw 19 | DQYJKoZIhvcNAQELBQADggIBALVoDm45ZhXcWandJis7ghx5Vc8ckZl6OFCVb+Qu 20 | 8z/22zqFe3nYUd+wyRXuyqbsAEgdILyQssTKZg9p89UlQGokTzC1y/XCM8Oq7cYY 21 | 9XNHsIxkwKbTVd2JYrPQe6Hh5O8thPy3n6kSQFf6x4Hgnj6Rjhnx8/vdcGtvTatq 22 | KGpqfTN+poU+e3kguUMbERPqTGBQ7jZGttp282CfZryxymG8j0uwBBOeM/eNt0AC 23 | cnxPGKjfYbLiVWxXb9TiJ9acK1Qv+Hin1gCodGWs8j8ObV0oF+yTZUEs9UUxMpl0 24 | KRGT8Ma4heVZKBXnASSR0eiaUYr9e5nbQKKfZhfheEu3u3YLW2Fj0/qQHDqxWX1l 25 | J188X96RxVL4B2dydo/lAaZc/3+YPZOtl4tavTc6s1vayTmrzsieISPYwOGLfcum 26 | Nfzk4ktlVhf0Di9gOryibOmfpE2E4/f4ujZB6bmsQ40GS3LcWdIdGkZU3opBiZP0 27 | WTa+UZto39EBb7u7HjCxv92KSmcz8WQzWnUKs6cNZBJ+Zw9F1R9ykQYX6tK4qbA4 28 | Nar53JC9Z3Zp/rV0zSG47VVhcZ1j3g2OlnHa1mcRWHn3H0X4O4GtTtdvBDDWpOsJ 29 | wtQMI2vGIp9T3AnIrxoInvmipPGWTq9FV/omCZE+TOMELfbsBnVtRA8kIU6tQnKb 30 | bH91 31 | -----END CERTIFICATE REQUEST----- 32 | -------------------------------------------------------------------------------- /util/jsontools/jsontools_test.go: -------------------------------------------------------------------------------- 1 | // Trivial Tickets Ticketsystem 2 | // Copyright (C) 2019 The Contributors 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // Package jsontools provides useful tools for encoding JSON 18 | // from a map. 19 | package jsontools 20 | 21 | import ( 22 | "testing" 23 | 24 | "github.com/stretchr/testify/assert" 25 | 26 | "github.com/mortenterhart/trivial-tickets/log/testlog" 27 | "github.com/mortenterhart/trivial-tickets/structs" 28 | ) 29 | 30 | /* 31 | * Ticketsystem Trivial Tickets 32 | * 33 | * Matriculation numbers: 3040018, 6694964, 3478222 34 | * Lecture: Programmieren II, INF16B 35 | * Lecturer: Herr Prof. Dr. Helmut Neemann 36 | * Institute: Duale Hochschule Baden-Württemberg Mosbach 37 | * 38 | * --------------- 39 | * 40 | * Package jsontools [tests] 41 | * Useful tools for encoding JSON 42 | */ 43 | 44 | func TestMapToJSON(t *testing.T) { 45 | testlog.BeginTest() 46 | defer testlog.EndTest() 47 | 48 | testProperties := structs.JSONMap{ 49 | "status": 200, 50 | "message": "OK", 51 | } 52 | 53 | expectedJSON := `{ 54 | "message": "OK", 55 | "status": 200 56 | }` 57 | 58 | result := MapToJSON(testProperties) 59 | 60 | t.Run("equalJson", func(t *testing.T) { 61 | assert.Equal(t, expectedJSON, string(result), "decoded JSON should be equal to the expected result") 62 | }) 63 | } 64 | -------------------------------------------------------------------------------- /www/templates/create_ticket.html: -------------------------------------------------------------------------------- 1 | 33 | 34 | {{define "create_ticket"}} 35 | {{if .IsLoggedIn}} 36 |