mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 15:40:40 +02:00
Merge branch 'make-all-files-LF' into 'master'
Change all files to LF See merge request spaceti-app/integrations/acs/colnod-connector!10
This commit is contained in:
commit
e2ab82b363
@ -1,240 +1,240 @@
|
|||||||
_type: export
|
_type: export
|
||||||
__export_format: 4
|
__export_format: 4
|
||||||
__export_date: 2019-10-01T14:13:03.279Z
|
__export_date: 2019-10-01T14:13:03.279Z
|
||||||
__export_source: insomnia.desktop.app:v6.6.2
|
__export_source: insomnia.desktop.app:v6.6.2
|
||||||
resources:
|
resources:
|
||||||
- _id: req_f0797b6411b144f0bf0a40d9300ee92f
|
- _id: req_f0797b6411b144f0bf0a40d9300ee92f
|
||||||
authentication:
|
authentication:
|
||||||
disabled: false
|
disabled: false
|
||||||
password: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0
|
password: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0
|
||||||
type: basic
|
type: basic
|
||||||
username: spaceti
|
username: spaceti
|
||||||
body:
|
body:
|
||||||
mimeType: application/json
|
mimeType: application/json
|
||||||
text: >-
|
text: >-
|
||||||
{
|
{
|
||||||
"username": "spaceti",
|
"username": "spaceti",
|
||||||
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0"
|
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0"
|
||||||
}
|
}
|
||||||
created: 1569905755136
|
created: 1569905755136
|
||||||
description: ""
|
description: ""
|
||||||
headers:
|
headers:
|
||||||
- id: pair_061d15d1294e412caca8300559541695
|
- id: pair_061d15d1294e412caca8300559541695
|
||||||
name: content-type
|
name: content-type
|
||||||
value: application/json
|
value: application/json
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755136
|
metaSortKey: -1569905755136
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1569934518963
|
modified: 1569934518963
|
||||||
name: Login user
|
name: Login user
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_9ef1d96e0e6d40ef9094250114269496
|
parentId: fld_9ef1d96e0e6d40ef9094250114269496
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: "{{ base_url }}/AaaManager/authSession"
|
url: "{{ base_url }}/AaaManager/authSession"
|
||||||
_type: request
|
_type: request
|
||||||
- _id: fld_9ef1d96e0e6d40ef9094250114269496
|
- _id: fld_9ef1d96e0e6d40ef9094250114269496
|
||||||
created: 1569905755142
|
created: 1569905755142
|
||||||
description: Login information ( token )
|
description: Login information ( token )
|
||||||
environment: {}
|
environment: {}
|
||||||
environmentPropertyOrder: null
|
environmentPropertyOrder: null
|
||||||
metaSortKey: -1569905755142
|
metaSortKey: -1569905755142
|
||||||
modified: 1569905755142
|
modified: 1569905755142
|
||||||
name: login
|
name: login
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: request_group
|
_type: request_group
|
||||||
- _id: wrk_43652e59afaf4825a8bbbf31e346f616
|
- _id: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
created: 1569905755149
|
created: 1569905755149
|
||||||
description: "Colnod system: [Product information](http://produkty.colsys.cz/colnod)
|
description: "Colnod system: [Product information](http://produkty.colsys.cz/colnod)
|
||||||
Jira issues: [Communicaiton with
|
Jira issues: [Communicaiton with
|
||||||
Colnod](https://spaceti.atlassian.net/secure/RapidBoard.jspa?rapidView=78\
|
Colnod](https://spaceti.atlassian.net/secure/RapidBoard.jspa?rapidView=78\
|
||||||
&projectKey=INT&modal=detail&selectedIssue=INT-3563)"
|
&projectKey=INT&modal=detail&selectedIssue=INT-3563)"
|
||||||
modified: 1569905755149
|
modified: 1569905755149
|
||||||
name: Colnod server 1.0.0
|
name: Colnod server 1.0.0
|
||||||
parentId: null
|
parentId: null
|
||||||
_type: workspace
|
_type: workspace
|
||||||
- _id: req_00f9f99d933c4638900385ffbbd4f8f7
|
- _id: req_00f9f99d933c4638900385ffbbd4f8f7
|
||||||
authentication:
|
authentication:
|
||||||
disabled: false
|
disabled: false
|
||||||
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
||||||
'b64::JC5pZA==::46b', 'never' %}"
|
'b64::JC5pZA==::46b', 'never' %}"
|
||||||
type: bearer
|
type: bearer
|
||||||
body:
|
body:
|
||||||
mimeType: application/json
|
mimeType: application/json
|
||||||
text: ""
|
text: ""
|
||||||
created: 1569905755134
|
created: 1569905755134
|
||||||
description: ""
|
description: ""
|
||||||
headers:
|
headers:
|
||||||
- id: pair_a2a3c43a20f64efbb8a4752c7e983c8e
|
- id: pair_a2a3c43a20f64efbb8a4752c7e983c8e
|
||||||
name: Content-Type
|
name: Content-Type
|
||||||
value: application/json
|
value: application/json
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755134
|
metaSortKey: -1569905755134
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1569937805044
|
modified: 1569937805044
|
||||||
name: Get subjects
|
name: Get subjects
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_2fb4c2cef1f44cff83d6b00fe0886384
|
parentId: fld_2fb4c2cef1f44cff83d6b00fe0886384
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: "{{ base_url }}/SubjectManager/getSubjects"
|
url: "{{ base_url }}/SubjectManager/getSubjects"
|
||||||
_type: request
|
_type: request
|
||||||
- _id: fld_2fb4c2cef1f44cff83d6b00fe0886384
|
- _id: fld_2fb4c2cef1f44cff83d6b00fe0886384
|
||||||
created: 1569905755140
|
created: 1569905755140
|
||||||
description: Operations about user
|
description: Operations about user
|
||||||
environment: {}
|
environment: {}
|
||||||
environmentPropertyOrder: null
|
environmentPropertyOrder: null
|
||||||
metaSortKey: -1569905755140
|
metaSortKey: -1569905755140
|
||||||
modified: 1569905755140
|
modified: 1569905755140
|
||||||
name: user
|
name: user
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: request_group
|
_type: request_group
|
||||||
- _id: req_9e42a5023f9d4235a5de099cd7573d2b
|
- _id: req_9e42a5023f9d4235a5de099cd7573d2b
|
||||||
authentication:
|
authentication:
|
||||||
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
||||||
'b64::JC5pZA==::46b', 'never' %}"
|
'b64::JC5pZA==::46b', 'never' %}"
|
||||||
type: bearer
|
type: bearer
|
||||||
body:
|
body:
|
||||||
mimeType: application/json
|
mimeType: application/json
|
||||||
text: |-
|
text: |-
|
||||||
{
|
{
|
||||||
"id": "1a23c502-1665-4492-94ea-039bb7505cae"
|
"id": "1a23c502-1665-4492-94ea-039bb7505cae"
|
||||||
}
|
}
|
||||||
created: 1569905755131
|
created: 1569905755131
|
||||||
description: ""
|
description: ""
|
||||||
headers:
|
headers:
|
||||||
- disabled: false
|
- disabled: false
|
||||||
id: pair_e888b6c679d74b0988f0dd2d77690383
|
id: pair_e888b6c679d74b0988f0dd2d77690383
|
||||||
name: Content-Type
|
name: Content-Type
|
||||||
value: application/json
|
value: application/json
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755131
|
metaSortKey: -1569905755131
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1569939013152
|
modified: 1569939013152
|
||||||
name: Get Tokens
|
name: Get Tokens
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_36a4be72380440a0ace83ad508a0458d
|
parentId: fld_36a4be72380440a0ace83ad508a0458d
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: "{{ base_url }}/TokenManager/getTokens/"
|
url: "{{ base_url }}/TokenManager/getTokens/"
|
||||||
_type: request
|
_type: request
|
||||||
- _id: fld_36a4be72380440a0ace83ad508a0458d
|
- _id: fld_36a4be72380440a0ace83ad508a0458d
|
||||||
created: 1569905755138
|
created: 1569905755138
|
||||||
description: Working with tokens ( keys )
|
description: Working with tokens ( keys )
|
||||||
environment: {}
|
environment: {}
|
||||||
environmentPropertyOrder: null
|
environmentPropertyOrder: null
|
||||||
metaSortKey: -1569905755138
|
metaSortKey: -1569905755138
|
||||||
modified: 1569934361048
|
modified: 1569934361048
|
||||||
name: Token Manager
|
name: Token Manager
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: request_group
|
_type: request_group
|
||||||
- _id: req_4f99d61a83c14da29882cc80c07ddf54
|
- _id: req_4f99d61a83c14da29882cc80c07ddf54
|
||||||
authentication:
|
authentication:
|
||||||
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
||||||
'b64::JC5pZA==::46b', 'never' %}"
|
'b64::JC5pZA==::46b', 'never' %}"
|
||||||
type: bearer
|
type: bearer
|
||||||
body: {}
|
body: {}
|
||||||
created: 1569905755127
|
created: 1569905755127
|
||||||
description: ""
|
description: ""
|
||||||
headers: []
|
headers: []
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755129
|
metaSortKey: -1569905755129
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1569938955854
|
modified: 1569938955854
|
||||||
name: Set Tokens
|
name: Set Tokens
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_36a4be72380440a0ace83ad508a0458d
|
parentId: fld_36a4be72380440a0ace83ad508a0458d
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: /TokenManager/setTokens
|
url: /TokenManager/setTokens
|
||||||
_type: request
|
_type: request
|
||||||
- _id: req_fd2e096f45554b46b31755564a0932bf
|
- _id: req_fd2e096f45554b46b31755564a0932bf
|
||||||
authentication:
|
authentication:
|
||||||
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
||||||
'b64::JC5pZA==::46b', 'never' %}"
|
'b64::JC5pZA==::46b', 'never' %}"
|
||||||
type: bearer
|
type: bearer
|
||||||
body: {}
|
body: {}
|
||||||
created: 1569934364782
|
created: 1569934364782
|
||||||
description: ""
|
description: ""
|
||||||
headers: []
|
headers: []
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755130.5
|
metaSortKey: -1569905755130.5
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1569937740242
|
modified: 1569937740242
|
||||||
name: Get Token Subject
|
name: Get Token Subject
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_8d34eca167ef426c8aa998c98bbe74e2
|
parentId: fld_8d34eca167ef426c8aa998c98bbe74e2
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: "{{ base_url }}/OpenManager/getTokenSubject"
|
url: "{{ base_url }}/OpenManager/getTokenSubject"
|
||||||
_type: request
|
_type: request
|
||||||
- _id: fld_8d34eca167ef426c8aa998c98bbe74e2
|
- _id: fld_8d34eca167ef426c8aa998c98bbe74e2
|
||||||
created: 1569934364777
|
created: 1569934364777
|
||||||
description: Working with tokens ( keys )
|
description: Working with tokens ( keys )
|
||||||
environment: {}
|
environment: {}
|
||||||
environmentPropertyOrder: null
|
environmentPropertyOrder: null
|
||||||
metaSortKey: -1569905755088
|
metaSortKey: -1569905755088
|
||||||
modified: 1569934370959
|
modified: 1569934370959
|
||||||
name: Open Manager
|
name: Open Manager
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: request_group
|
_type: request_group
|
||||||
- _id: env_7bc4918f1ec5467393a2ab36a460e4d0
|
- _id: env_7bc4918f1ec5467393a2ab36a460e4d0
|
||||||
color: null
|
color: null
|
||||||
created: 1569905755147
|
created: 1569905755147
|
||||||
data:
|
data:
|
||||||
base_url: "{{ scheme }}://{{ host }}{{ base_path }}"
|
base_url: "{{ scheme }}://{{ host }}{{ base_path }}"
|
||||||
dataPropertyOrder:
|
dataPropertyOrder:
|
||||||
"&":
|
"&":
|
||||||
- base_url
|
- base_url
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: 1569905755147
|
metaSortKey: 1569905755147
|
||||||
modified: 1569905805832
|
modified: 1569905805832
|
||||||
name: Base environment
|
name: Base environment
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: environment
|
_type: environment
|
||||||
- _id: jar_61bbb3fdc5ee80a49ee817b3e5341053a6022960
|
- _id: jar_61bbb3fdc5ee80a49ee817b3e5341053a6022960
|
||||||
cookies:
|
cookies:
|
||||||
- creation: 2019-10-01T04:57:46.521Z
|
- creation: 2019-10-01T04:57:46.521Z
|
||||||
domain: 192.168.1.3
|
domain: 192.168.1.3
|
||||||
hostOnly: true
|
hostOnly: true
|
||||||
httpOnly: true
|
httpOnly: true
|
||||||
id: "40058861704510274"
|
id: "40058861704510274"
|
||||||
key: JSESSIONID
|
key: JSESSIONID
|
||||||
lastAccessed: 2019-10-01T14:08:27.635Z
|
lastAccessed: 2019-10-01T14:08:27.635Z
|
||||||
path: /
|
path: /
|
||||||
secure: true
|
secure: true
|
||||||
value: 2A63FF79AC604DB88D26DE41876B8B88
|
value: 2A63FF79AC604DB88D26DE41876B8B88
|
||||||
created: 1569905764431
|
created: 1569905764431
|
||||||
modified: 1569938907635
|
modified: 1569938907635
|
||||||
name: Default Jar
|
name: Default Jar
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: cookie_jar
|
_type: cookie_jar
|
||||||
- _id: env_92b9543a27e847689c951d1b1eeff229
|
- _id: env_92b9543a27e847689c951d1b1eeff229
|
||||||
color: "#cb5dc2"
|
color: "#cb5dc2"
|
||||||
created: 1569905755144
|
created: 1569905755144
|
||||||
data:
|
data:
|
||||||
base_path: /
|
base_path: /
|
||||||
host: 192.168.1.3:8443
|
host: 192.168.1.3:8443
|
||||||
scheme: https
|
scheme: https
|
||||||
dataPropertyOrder: null
|
dataPropertyOrder: null
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: 1569905755144
|
metaSortKey: 1569905755144
|
||||||
modified: 1569935791597
|
modified: 1569935791597
|
||||||
name: colnod-test
|
name: colnod-test
|
||||||
parentId: env_7bc4918f1ec5467393a2ab36a460e4d0
|
parentId: env_7bc4918f1ec5467393a2ab36a460e4d0
|
||||||
_type: environment
|
_type: environment
|
||||||
|
|||||||
@ -1,270 +1,270 @@
|
|||||||
_type: export
|
_type: export
|
||||||
__export_format: 4
|
__export_format: 4
|
||||||
__export_date: 2019-10-02T15:35:40.243Z
|
__export_date: 2019-10-02T15:35:40.243Z
|
||||||
__export_source: insomnia.desktop.app:v6.6.2
|
__export_source: insomnia.desktop.app:v6.6.2
|
||||||
resources:
|
resources:
|
||||||
- _id: req_f0797b6411b144f0bf0a40d9300ee92f
|
- _id: req_f0797b6411b144f0bf0a40d9300ee92f
|
||||||
authentication:
|
authentication:
|
||||||
disabled: false
|
disabled: false
|
||||||
password: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0
|
password: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0
|
||||||
type: basic
|
type: basic
|
||||||
username: spaceti
|
username: spaceti
|
||||||
body:
|
body:
|
||||||
mimeType: application/json
|
mimeType: application/json
|
||||||
text: >-
|
text: >-
|
||||||
{
|
{
|
||||||
"username": "spaceti",
|
"username": "spaceti",
|
||||||
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0"
|
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0"
|
||||||
}
|
}
|
||||||
created: 1569905755136
|
created: 1569905755136
|
||||||
description: ""
|
description: ""
|
||||||
headers:
|
headers:
|
||||||
- id: pair_061d15d1294e412caca8300559541695
|
- id: pair_061d15d1294e412caca8300559541695
|
||||||
name: content-type
|
name: content-type
|
||||||
value: application/json
|
value: application/json
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755136
|
metaSortKey: -1569905755136
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1570026752164
|
modified: 1570026752164
|
||||||
name: Login user
|
name: Login user
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_9ef1d96e0e6d40ef9094250114269496
|
parentId: fld_9ef1d96e0e6d40ef9094250114269496
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: "{{ base_url }}/AaaManager/authSession"
|
url: "{{ base_url }}/AaaManager/authSession"
|
||||||
_type: request
|
_type: request
|
||||||
- _id: fld_9ef1d96e0e6d40ef9094250114269496
|
- _id: fld_9ef1d96e0e6d40ef9094250114269496
|
||||||
created: 1569905755142
|
created: 1569905755142
|
||||||
description: Login information ( token )
|
description: Login information ( token )
|
||||||
environment: {}
|
environment: {}
|
||||||
environmentPropertyOrder: null
|
environmentPropertyOrder: null
|
||||||
metaSortKey: -1569905755142
|
metaSortKey: -1569905755142
|
||||||
modified: 1569905755142
|
modified: 1569905755142
|
||||||
name: login
|
name: login
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: request_group
|
_type: request_group
|
||||||
- _id: wrk_43652e59afaf4825a8bbbf31e346f616
|
- _id: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
created: 1569905755149
|
created: 1569905755149
|
||||||
description: "Colnod system: [Product information](http://produkty.colsys.cz/colnod)
|
description: "Colnod system: [Product information](http://produkty.colsys.cz/colnod)
|
||||||
Jira issues: [Communicaiton with
|
Jira issues: [Communicaiton with
|
||||||
Colnod](https://spaceti.atlassian.net/secure/RapidBoard.jspa?rapidView=78\
|
Colnod](https://spaceti.atlassian.net/secure/RapidBoard.jspa?rapidView=78\
|
||||||
&projectKey=INT&modal=detail&selectedIssue=INT-3563)"
|
&projectKey=INT&modal=detail&selectedIssue=INT-3563)"
|
||||||
modified: 1569905755149
|
modified: 1569905755149
|
||||||
name: Colnod server 1.0.0
|
name: Colnod server 1.0.0
|
||||||
parentId: null
|
parentId: null
|
||||||
_type: workspace
|
_type: workspace
|
||||||
- _id: req_00f9f99d933c4638900385ffbbd4f8f7
|
- _id: req_00f9f99d933c4638900385ffbbd4f8f7
|
||||||
authentication:
|
authentication:
|
||||||
disabled: false
|
disabled: false
|
||||||
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
||||||
'b64::JC5pZA==::46b', 'no-history' %}"
|
'b64::JC5pZA==::46b', 'no-history' %}"
|
||||||
type: bearer
|
type: bearer
|
||||||
body:
|
body:
|
||||||
mimeType: application/json
|
mimeType: application/json
|
||||||
text: ""
|
text: ""
|
||||||
created: 1569905755134
|
created: 1569905755134
|
||||||
description: ""
|
description: ""
|
||||||
headers:
|
headers:
|
||||||
- id: pair_a2a3c43a20f64efbb8a4752c7e983c8e
|
- id: pair_a2a3c43a20f64efbb8a4752c7e983c8e
|
||||||
name: Content-Type
|
name: Content-Type
|
||||||
value: application/json
|
value: application/json
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755134
|
metaSortKey: -1569905755134
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1570025488293
|
modified: 1570025488293
|
||||||
name: Get subjects
|
name: Get subjects
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_2fb4c2cef1f44cff83d6b00fe0886384
|
parentId: fld_2fb4c2cef1f44cff83d6b00fe0886384
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: "{{ base_url }}/SubjectManager/getSubjects"
|
url: "{{ base_url }}/SubjectManager/getSubjects"
|
||||||
_type: request
|
_type: request
|
||||||
- _id: fld_2fb4c2cef1f44cff83d6b00fe0886384
|
- _id: fld_2fb4c2cef1f44cff83d6b00fe0886384
|
||||||
created: 1569905755140
|
created: 1569905755140
|
||||||
description: Operations about user
|
description: Operations about user
|
||||||
environment: {}
|
environment: {}
|
||||||
environmentPropertyOrder: null
|
environmentPropertyOrder: null
|
||||||
metaSortKey: -1569905755140
|
metaSortKey: -1569905755140
|
||||||
modified: 1569905755140
|
modified: 1569905755140
|
||||||
name: user
|
name: user
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: request_group
|
_type: request_group
|
||||||
- _id: req_9e42a5023f9d4235a5de099cd7573d2b
|
- _id: req_9e42a5023f9d4235a5de099cd7573d2b
|
||||||
authentication:
|
authentication:
|
||||||
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
||||||
'b64::JC5pZA==::46b', 'never' %}"
|
'b64::JC5pZA==::46b', 'never' %}"
|
||||||
type: bearer
|
type: bearer
|
||||||
body:
|
body:
|
||||||
mimeType: application/json
|
mimeType: application/json
|
||||||
text: ""
|
text: ""
|
||||||
created: 1569905755131
|
created: 1569905755131
|
||||||
description: ""
|
description: ""
|
||||||
headers:
|
headers:
|
||||||
- disabled: false
|
- disabled: false
|
||||||
id: pair_e888b6c679d74b0988f0dd2d77690383
|
id: pair_e888b6c679d74b0988f0dd2d77690383
|
||||||
name: Content-Type
|
name: Content-Type
|
||||||
value: application/json
|
value: application/json
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755131
|
metaSortKey: -1569905755131
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1569998661557
|
modified: 1569998661557
|
||||||
name: Get Tokens
|
name: Get Tokens
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_36a4be72380440a0ace83ad508a0458d
|
parentId: fld_36a4be72380440a0ace83ad508a0458d
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: "{{ base_url }}/TokenManager/getTokens/"
|
url: "{{ base_url }}/TokenManager/getTokens/"
|
||||||
_type: request
|
_type: request
|
||||||
- _id: fld_36a4be72380440a0ace83ad508a0458d
|
- _id: fld_36a4be72380440a0ace83ad508a0458d
|
||||||
created: 1569905755138
|
created: 1569905755138
|
||||||
description: Working with tokens ( keys )
|
description: Working with tokens ( keys )
|
||||||
environment: {}
|
environment: {}
|
||||||
environmentPropertyOrder: null
|
environmentPropertyOrder: null
|
||||||
metaSortKey: -1569905755138
|
metaSortKey: -1569905755138
|
||||||
modified: 1569934361048
|
modified: 1569934361048
|
||||||
name: Token Manager
|
name: Token Manager
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: request_group
|
_type: request_group
|
||||||
- _id: req_4f99d61a83c14da29882cc80c07ddf54
|
- _id: req_4f99d61a83c14da29882cc80c07ddf54
|
||||||
authentication:
|
authentication:
|
||||||
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
token: "{% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
||||||
'b64::JC5pZA==::46b', 'never' %}"
|
'b64::JC5pZA==::46b', 'never' %}"
|
||||||
type: bearer
|
type: bearer
|
||||||
body: {}
|
body: {}
|
||||||
created: 1569905755127
|
created: 1569905755127
|
||||||
description: ""
|
description: ""
|
||||||
headers: []
|
headers: []
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755129
|
metaSortKey: -1569905755129
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1569938955854
|
modified: 1569938955854
|
||||||
name: Set Tokens
|
name: Set Tokens
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_36a4be72380440a0ace83ad508a0458d
|
parentId: fld_36a4be72380440a0ace83ad508a0458d
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: /TokenManager/setTokens
|
url: /TokenManager/setTokens
|
||||||
_type: request
|
_type: request
|
||||||
- _id: req_fd2e096f45554b46b31755564a0932bf
|
- _id: req_fd2e096f45554b46b31755564a0932bf
|
||||||
authentication:
|
authentication:
|
||||||
token: {% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
token: {% response 'body', 'req_f0797b6411b144f0bf0a40d9300ee92f',
|
||||||
'b64::JC5pZA==::46b', 'no-history' %}
|
'b64::JC5pZA==::46b', 'no-history' %}
|
||||||
type: bearer
|
type: bearer
|
||||||
body: {}
|
body: {}
|
||||||
created: 1569934364782
|
created: 1569934364782
|
||||||
description: ""
|
description: ""
|
||||||
headers: []
|
headers: []
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755130.5
|
metaSortKey: -1569905755130.5
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1570028425988
|
modified: 1570028425988
|
||||||
name: Get Token Subject
|
name: Get Token Subject
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_8d34eca167ef426c8aa998c98bbe74e2
|
parentId: fld_8d34eca167ef426c8aa998c98bbe74e2
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: "{{ base_url }}/OpenManager/getTokenSubject"
|
url: "{{ base_url }}/OpenManager/getTokenSubject"
|
||||||
_type: request
|
_type: request
|
||||||
- _id: fld_8d34eca167ef426c8aa998c98bbe74e2
|
- _id: fld_8d34eca167ef426c8aa998c98bbe74e2
|
||||||
created: 1569934364777
|
created: 1569934364777
|
||||||
description: Working with tokens ( keys )
|
description: Working with tokens ( keys )
|
||||||
environment: {}
|
environment: {}
|
||||||
environmentPropertyOrder: null
|
environmentPropertyOrder: null
|
||||||
metaSortKey: -1569905755088
|
metaSortKey: -1569905755088
|
||||||
modified: 1569934370959
|
modified: 1569934370959
|
||||||
name: Open Manager
|
name: Open Manager
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: request_group
|
_type: request_group
|
||||||
- _id: req_7007bb1f6a0243a7b0568741f691f6d1
|
- _id: req_7007bb1f6a0243a7b0568741f691f6d1
|
||||||
authentication:
|
authentication:
|
||||||
disabled: false
|
disabled: false
|
||||||
password: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0
|
password: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0
|
||||||
type: basic
|
type: basic
|
||||||
username: spaceti
|
username: spaceti
|
||||||
body:
|
body:
|
||||||
mimeType: application/json
|
mimeType: application/json
|
||||||
text: >-
|
text: >-
|
||||||
{
|
{
|
||||||
"username": "spaceti",
|
"username": "spaceti",
|
||||||
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0"
|
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0"
|
||||||
}
|
}
|
||||||
created: 1570025458784
|
created: 1570025458784
|
||||||
description: ""
|
description: ""
|
||||||
headers:
|
headers:
|
||||||
- id: pair_74b4df5d54d1446a90e6a668d373fb79
|
- id: pair_74b4df5d54d1446a90e6a668d373fb79
|
||||||
name: Content-Type
|
name: Content-Type
|
||||||
value: application/json
|
value: application/json
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: -1569905755129.75
|
metaSortKey: -1569905755129.75
|
||||||
method: POST
|
method: POST
|
||||||
modified: 1570030518745
|
modified: 1570030518745
|
||||||
name: Get Token Subject Full authorization
|
name: Get Token Subject Full authorization
|
||||||
parameters: []
|
parameters: []
|
||||||
parentId: fld_8d34eca167ef426c8aa998c98bbe74e2
|
parentId: fld_8d34eca167ef426c8aa998c98bbe74e2
|
||||||
settingDisableRenderRequestBody: false
|
settingDisableRenderRequestBody: false
|
||||||
settingEncodeUrl: true
|
settingEncodeUrl: true
|
||||||
settingRebuildPath: true
|
settingRebuildPath: true
|
||||||
settingSendCookies: true
|
settingSendCookies: true
|
||||||
settingStoreCookies: true
|
settingStoreCookies: true
|
||||||
url: "{{ base_url }}/OpenManager/getTokenSubject"
|
url: "{{ base_url }}/OpenManager/getTokenSubject"
|
||||||
_type: request
|
_type: request
|
||||||
- _id: env_7bc4918f1ec5467393a2ab36a460e4d0
|
- _id: env_7bc4918f1ec5467393a2ab36a460e4d0
|
||||||
color: null
|
color: null
|
||||||
created: 1569905755147
|
created: 1569905755147
|
||||||
data:
|
data:
|
||||||
base_url: "{{ scheme }}://{{ host }}{{ base_path }}"
|
base_url: "{{ scheme }}://{{ host }}{{ base_path }}"
|
||||||
dataPropertyOrder:
|
dataPropertyOrder:
|
||||||
"&":
|
"&":
|
||||||
- base_url
|
- base_url
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: 1569905755147
|
metaSortKey: 1569905755147
|
||||||
modified: 1569905805832
|
modified: 1569905805832
|
||||||
name: Base environment
|
name: Base environment
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: environment
|
_type: environment
|
||||||
- _id: jar_61bbb3fdc5ee80a49ee817b3e5341053a6022960
|
- _id: jar_61bbb3fdc5ee80a49ee817b3e5341053a6022960
|
||||||
cookies:
|
cookies:
|
||||||
- creation: 2019-10-01T04:57:46.521Z
|
- creation: 2019-10-01T04:57:46.521Z
|
||||||
domain: 192.168.1.3
|
domain: 192.168.1.3
|
||||||
hostOnly: true
|
hostOnly: true
|
||||||
httpOnly: true
|
httpOnly: true
|
||||||
id: "9919962998126108"
|
id: "9919962998126108"
|
||||||
key: JSESSIONID
|
key: JSESSIONID
|
||||||
lastAccessed: 2019-10-02T15:35:00.995Z
|
lastAccessed: 2019-10-02T15:35:00.995Z
|
||||||
path: /
|
path: /
|
||||||
secure: true
|
secure: true
|
||||||
value: D64B135F2F3D5103F02F0B9235B13722
|
value: D64B135F2F3D5103F02F0B9235B13722
|
||||||
created: 1569905764431
|
created: 1569905764431
|
||||||
modified: 1570030500995
|
modified: 1570030500995
|
||||||
name: Default Jar
|
name: Default Jar
|
||||||
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
parentId: wrk_43652e59afaf4825a8bbbf31e346f616
|
||||||
_type: cookie_jar
|
_type: cookie_jar
|
||||||
- _id: env_92b9543a27e847689c951d1b1eeff229
|
- _id: env_92b9543a27e847689c951d1b1eeff229
|
||||||
color: "#cb5dc2"
|
color: "#cb5dc2"
|
||||||
created: 1569905755144
|
created: 1569905755144
|
||||||
data:
|
data:
|
||||||
base_path: /
|
base_path: /
|
||||||
host: 192.168.1.3:8443
|
host: 192.168.1.3:8443
|
||||||
scheme: https
|
scheme: https
|
||||||
dataPropertyOrder: null
|
dataPropertyOrder: null
|
||||||
isPrivate: false
|
isPrivate: false
|
||||||
metaSortKey: 1569905755144
|
metaSortKey: 1569905755144
|
||||||
modified: 1569935791597
|
modified: 1569935791597
|
||||||
name: colnod-test
|
name: colnod-test
|
||||||
parentId: env_7bc4918f1ec5467393a2ab36a460e4d0
|
parentId: env_7bc4918f1ec5467393a2ab36a460e4d0
|
||||||
_type: environment
|
_type: environment
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
TOKEN=$(curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0" -d '{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}' -H "Content-Type: application/json" https://192.168.1.3:8443/AaaManager/authSession 2>/dev/null | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["id"]')
|
TOKEN=$(curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0" -d '{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}' -H "Content-Type: application/json" https://192.168.1.3:8443/AaaManager/authSession 2>/dev/null | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["id"]')
|
||||||
|
|
||||||
|
|
||||||
curl -kv -u "$TOKEN:" -X POST https://192.168.1.3:8443/SubjectManager/getSubjects
|
curl -kv -u "$TOKEN:" -X POST https://192.168.1.3:8443/SubjectManager/getSubjects
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
TOKEN=$(curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0" -d '{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}' -H "Content-Type: application/json" https://192.168.1.3:8443/AaaManager/authSession 2>/dev/null | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["id"]')
|
TOKEN=$(curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0" -d '{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}' -H "Content-Type: application/json" https://192.168.1.3:8443/AaaManager/authSession 2>/dev/null | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["id"]')
|
||||||
|
|
||||||
|
|
||||||
curl -kv -u "$TOKEN:" -X POST https://192.168.1.3:8443/TokenManager/getTokens/
|
curl -kv -u "$TOKEN:" -X POST https://192.168.1.3:8443/TokenManager/getTokens/
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
TOKEN=$(curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0" -d '{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}' -H "Content-Type: application/json" https://192.168.1.3:8443/AaaManager/authSession 2>/dev/null | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["id"]')
|
TOKEN=$(curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0" -d '{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}' -H "Content-Type: application/json" https://192.168.1.3:8443/AaaManager/authSession 2>/dev/null | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["id"]')
|
||||||
echo TOKEN
|
echo TOKEN
|
||||||
curl -kv -u "$TOKEN:" -X POST https://192.168.1.3:8443/OpenManager/getTokenSubject
|
curl -kv -u "$TOKEN:" -X POST https://192.168.1.3:8443/OpenManager/getTokenSubject
|
||||||
|
|||||||
@ -1,37 +1,37 @@
|
|||||||
|
|
||||||
///SubjectManager/getSubjects
|
///SubjectManager/getSubjects
|
||||||
RESPONSE
|
RESPONSE
|
||||||
HTTP/1.1 200
|
HTTP/1.1 200
|
||||||
X-Content-Type-Options: nosniff
|
X-Content-Type-Options: nosniff
|
||||||
X-XSS-Protection: 1; mode=block
|
X-XSS-Protection: 1; mode=block
|
||||||
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
|
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
|
||||||
Pragma: no-cache
|
Pragma: no-cache
|
||||||
Expires: 0
|
Expires: 0
|
||||||
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
|
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
|
||||||
X-Frame-Options: DENY
|
X-Frame-Options: DENY
|
||||||
Set-Cookie: JSESSIONID=77278D21902AE1DE75E43204C2770545;path=/;Secure;HttpOnly
|
Set-Cookie: JSESSIONID=77278D21902AE1DE75E43204C2770545;path=/;Secure;HttpOnly
|
||||||
Content-Type: application/json;charset=UTF-8
|
Content-Type: application/json;charset=UTF-8
|
||||||
Transfer-Encoding: chunked
|
Transfer-Encoding: chunked
|
||||||
Date: Thu, 03 Oct 2019 11:12:03 GMT
|
Date: Thu, 03 Oct 2019 11:12:03 GMT
|
||||||
|
|
||||||
REQUEST
|
REQUEST
|
||||||
POST /SubjectManager/getSubjects HTTP/1.1
|
POST /SubjectManager/getSubjects HTTP/1.1
|
||||||
Host: 192.168.1.3:8443
|
Host: 192.168.1.3:8443
|
||||||
Authorization: Basic ODkwZjllNmMtMDIxNi00ZThiLWI2MjgtMjViOGI2ZmFiNWM4Og==
|
Authorization: Basic ODkwZjllNmMtMDIxNi00ZThiLWI2MjgtMjViOGI2ZmFiNWM4Og==
|
||||||
User-Agent: curl/7.65.3
|
User-Agent: curl/7.65.3
|
||||||
Accept: */*
|
Accept: */*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
POST /AaaManager/authSession HTTP/1.1
|
POST /AaaManager/authSession HTTP/1.1
|
||||||
Host: localhost:8080
|
Host: localhost:8080
|
||||||
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
||||||
User-Agent: curl/7.65.3
|
User-Agent: curl/7.65.3
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Content-Length: 164
|
Content-Length: 164
|
||||||
|
|
||||||
{
|
{
|
||||||
"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0",
|
"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0",
|
||||||
"username":"spaceti"
|
"username":"spaceti"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
POST /OpenManager/getTokenSubject HTTP/1.1
|
POST /OpenManager/getTokenSubject HTTP/1.1
|
||||||
Host: localhost:8080
|
Host: localhost:8080
|
||||||
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
||||||
User-Agent: insomnia/7.0.0
|
User-Agent: insomnia/7.0.0
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 173
|
Content-Length: 173
|
||||||
|
|
||||||
{
|
{
|
||||||
"username": "spaceti",
|
"username": "spaceti",
|
||||||
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0"
|
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,24 +1,24 @@
|
|||||||
POST /AaaManager/authSession HTTP/1.1
|
POST /AaaManager/authSession HTTP/1.1
|
||||||
Host: localhost:8080
|
Host: localhost:8080
|
||||||
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
||||||
Content-Type: application/json; charset=UTF-8
|
Content-Type: application/json; charset=UTF-8
|
||||||
Content-Length: 178
|
Content-Length: 178
|
||||||
Connection: Keep-Alive
|
Connection: Keep-Alive
|
||||||
Accept-Encoding: gzip, deflate
|
Accept-Encoding: gzip, deflate
|
||||||
Accept-Language: en-AI,*
|
Accept-Language: en-AI,*
|
||||||
User-Agent: Mozilla/5.0
|
User-Agent: Mozilla/5.0
|
||||||
|
|
||||||
{
|
{
|
||||||
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0",
|
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0",
|
||||||
"username": "spaceti"
|
"username": "spaceti"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//no data because cant get token
|
//no data because cant get token
|
||||||
POST /SubjectManager/getSubjects HTTP/1.1
|
POST /SubjectManager/getSubjects HTTP/1.1
|
||||||
Host: localhost:8080
|
Host: localhost:8080
|
||||||
Content-Length: 0
|
Content-Length: 0
|
||||||
Connection: Keep-Alive
|
Connection: Keep-Alive
|
||||||
Accept-Encoding: gzip, deflate
|
Accept-Encoding: gzip, deflate
|
||||||
Accept-Language: en-AI,*
|
Accept-Language: en-AI,*
|
||||||
User-Agent: Mozilla/5.0
|
User-Agent: Mozilla/5.0
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
POST /AaaManager/authSession HTTP/1.1
|
POST /AaaManager/authSession HTTP/1.1
|
||||||
Host: localhost:8080
|
Host: localhost:8080
|
||||||
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
||||||
User-Agent: curl/7.65.3
|
User-Agent: curl/7.65.3
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Content-Length: 164
|
Content-Length: 164
|
||||||
|
|
||||||
{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}
|
{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
POST /SubjectManager/getSubjects HTTP/1.1
|
POST /SubjectManager/getSubjects HTTP/1.1
|
||||||
Host: localhost:8080
|
Host: localhost:8080
|
||||||
Authorization: Basic ZmYwMzYwZjYtMzRmZC00ZjAwLTlhNTYtMWZiMzhmNjlhNDIzOg==
|
Authorization: Basic ZmYwMzYwZjYtMzRmZC00ZjAwLTlhNTYtMWZiMzhmNjlhNDIzOg==
|
||||||
User-Agent: curl/7.65.3
|
User-Agent: curl/7.65.3
|
||||||
Accept: */*
|
Accept: */*
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
POST /AaaManager/authSession HTTP/1.1
|
POST /AaaManager/authSession HTTP/1.1
|
||||||
Host: localhost:8080
|
Host: localhost:8080
|
||||||
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
||||||
Content-Type: application/json; charset=UTF-8
|
Content-Type: application/json; charset=UTF-8
|
||||||
Content-Length: 178
|
Content-Length: 178
|
||||||
Connection: Keep-Alive
|
Connection: Keep-Alive
|
||||||
Accept-Encoding: gzip, deflate
|
Accept-Encoding: gzip, deflate
|
||||||
Accept-Language: en-AI,*
|
Accept-Language: en-AI,*
|
||||||
User-Agent: Mozilla/5.0
|
User-Agent: Mozilla/5.0
|
||||||
|
|
||||||
{
|
{
|
||||||
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0",
|
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0",
|
||||||
"username": "spaceti"
|
"username": "spaceti"
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
POST /AaaManager/authSession HTTP/1.1
|
POST /AaaManager/authSession HTTP/1.1
|
||||||
Host: localhost:8080
|
Host: localhost:8080
|
||||||
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
Authorization: Basic c3BhY2V0aTpFN0ZFQTA3REJDODJGQjlCQTM0QjJFNDUzRTJFRkU4OUYwNTgzRTcxODc1NDM1MDdFRjExRTg0NzI2MDcxRkU0Mjg0NDUzNzJGMkU0NkI0NTVFQjBDNzk3NDdDNTFFMzYyRjQwM0NFMzk0NzNBMkE4QzJERkEwQ0U1Qzk4MjZDMA==
|
||||||
Content-Type: application/json; charset=UTF-8
|
Content-Type: application/json; charset=UTF-8
|
||||||
Content-Length: 178
|
Content-Length: 178
|
||||||
Connection: Keep-Alive
|
Connection: Keep-Alive
|
||||||
Accept-Encoding: gzip, deflate
|
Accept-Encoding: gzip, deflate
|
||||||
Accept-Language: en-AI,*
|
Accept-Language: en-AI,*
|
||||||
User-Agent: Mozilla/5.0
|
User-Agent: Mozilla/5.0
|
||||||
|
|
||||||
{
|
{
|
||||||
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0",
|
"password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0",
|
||||||
"username": "spaceti"
|
"username": "spaceti"
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
POST /SubjectManager/getSubjects HTTP/1.1
|
POST /SubjectManager/getSubjects HTTP/1.1
|
||||||
Host: localhost:8080
|
Host: localhost:8080
|
||||||
Content-Length: 0
|
Content-Length: 0
|
||||||
Connection: Keep-Alive
|
Connection: Keep-Alive
|
||||||
Accept-Encoding: gzip, deflate
|
Accept-Encoding: gzip, deflate
|
||||||
Accept-Language: en-AI,*
|
Accept-Language: en-AI,*
|
||||||
User-Agent: Mozilla/5.0
|
User-Agent: Mozilla/5.0
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
POST /SubjectManager/getSubjects HTTP/1.1
|
POST /SubjectManager/getSubjects HTTP/1.1
|
||||||
Host: localhost:8080
|
Host: localhost:8080
|
||||||
Content-Length: 0
|
Content-Length: 0
|
||||||
Connection: Keep-Alive
|
Connection: Keep-Alive
|
||||||
Accept-Encoding: gzip, deflate
|
Accept-Encoding: gzip, deflate
|
||||||
Accept-Language: en-AI,*
|
Accept-Language: en-AI,*
|
||||||
User-Agent: Mozilla/5.0
|
User-Agent: Mozilla/5.0
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
POST /SubjectManager/getSubjects HTTP/1.1
|
POST /SubjectManager/getSubjects HTTP/1.1
|
||||||
Host: 192.168.1.3:8443
|
Host: 192.168.1.3:8443
|
||||||
Authorization: Basic " + tkn.toUtf8().toBase64() + "
|
Authorization: Basic " + tkn.toUtf8().toBase64() + "
|
||||||
User-Agent: curl/7.65.3
|
User-Agent: curl/7.65.3
|
||||||
Accept: */*
|
Accept: */*
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
|
||||||
QT += core sql network
|
QT += core sql network
|
||||||
CONFIG += debug console
|
CONFIG += debug console
|
||||||
|
|
||||||
SOURCES += main.cpp
|
SOURCES += main.cpp
|
||||||
|
|
||||||
include(../colnod/colnod.pri)
|
include(../colnod/colnod.pri)
|
||||||
|
|||||||
@ -1,34 +1,34 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
#include "datamanager.h"
|
#include "datamanager.h"
|
||||||
#include "syncmanager.h"
|
#include "syncmanager.h"
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
QCoreApplication::setApplicationName("colnod-connector");
|
QCoreApplication::setApplicationName("colnod-connector");
|
||||||
QCoreApplication::setApplicationVersion("1.0");
|
QCoreApplication::setApplicationVersion("1.0");
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
Logger *logger = Logger::getLogger();
|
Logger *logger = Logger::getLogger();
|
||||||
parser.setApplicationDescription("Colnod sync");
|
parser.setApplicationDescription("Colnod sync");
|
||||||
QCommandLineOption dryModeOption("dryMode", "ColnodAPI", "Read-only mode, prints changes which would normally be made");
|
QCommandLineOption dryModeOption("dryMode", "ColnodAPI", "Read-only mode, prints changes which would normally be made");
|
||||||
parser.addOption(dryModeOption);
|
parser.addOption(dryModeOption);
|
||||||
parser.process(app);
|
parser.process(app);
|
||||||
SyncManager api(parser.isSet(dryModeOption));
|
SyncManager api(parser.isSet(dryModeOption));
|
||||||
api.loadDataFromDB();
|
api.loadDataFromDB();
|
||||||
api.loadDataFromColnod();
|
api.loadDataFromColnod();
|
||||||
QObject::connect(&api, &SyncManager::dataDownloaded, [&](){
|
QObject::connect(&api, &SyncManager::dataDownloaded, [&](){
|
||||||
QObject::connect(&api, &SyncManager::syncFinished, [](){
|
QObject::connect(&api, &SyncManager::syncFinished, [](){
|
||||||
qDebug() << "Quit";
|
qDebug() << "Quit";
|
||||||
QCoreApplication::exit();
|
QCoreApplication::exit();
|
||||||
});
|
});
|
||||||
api.syncDataFromColnodToDB();
|
api.syncDataFromColnodToDB();
|
||||||
api.syncDataFromDBToColnod();
|
api.syncDataFromDBToColnod();
|
||||||
});
|
});
|
||||||
QObject::connect(&api, &SyncManager::error, &app, [](){
|
QObject::connect(&api, &SyncManager::error, &app, [](){
|
||||||
qDebug() << "error";
|
qDebug() << "error";
|
||||||
QCoreApplication::exit(1);
|
QCoreApplication::exit(1);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
return QCoreApplication::exec();
|
return QCoreApplication::exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
INCLUDEPATH += $$PWD
|
INCLUDEPATH += $$PWD
|
||||||
#SRC_DIR = $$PWD
|
#SRC_DIR = $$PWD
|
||||||
message($$PWD)
|
message($$PWD)
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/databasemanager.cpp \
|
$$PWD/databasemanager.cpp \
|
||||||
$$PWD/datamanager.cpp \
|
$$PWD/datamanager.cpp \
|
||||||
$$PWD/entity.cpp \
|
$$PWD/entity.cpp \
|
||||||
$$PWD/logger.cpp \
|
$$PWD/logger.cpp \
|
||||||
$$PWD/requestmanager.cpp \
|
$$PWD/requestmanager.cpp \
|
||||||
$$PWD/response.cpp \
|
$$PWD/response.cpp \
|
||||||
$$PWD/subject.cpp \
|
$$PWD/subject.cpp \
|
||||||
$$PWD/syncmanager.cpp \
|
$$PWD/syncmanager.cpp \
|
||||||
$$PWD/token.cpp
|
$$PWD/token.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/databasemanager.h \
|
$$PWD/databasemanager.h \
|
||||||
$$PWD/datamanager.h \
|
$$PWD/datamanager.h \
|
||||||
$$PWD/entity.h \
|
$$PWD/entity.h \
|
||||||
$$PWD/logger.h \
|
$$PWD/logger.h \
|
||||||
$$PWD/requestmanager.h \
|
$$PWD/requestmanager.h \
|
||||||
$$PWD/response.h \
|
$$PWD/response.h \
|
||||||
$$PWD/subject.h \
|
$$PWD/subject.h \
|
||||||
$$PWD/syncmanager.h \
|
$$PWD/syncmanager.h \
|
||||||
$$PWD/token.h
|
$$PWD/token.h
|
||||||
message($$SOURCES)
|
message($$SOURCES)
|
||||||
|
|||||||
@ -1,311 +1,311 @@
|
|||||||
#include "databasemanager.h"
|
#include "databasemanager.h"
|
||||||
|
|
||||||
DatabaseManager::DatabaseManager(const QString& host, const QString& dbName, const QString& user, const QString& password, const bool &dryMode)
|
DatabaseManager::DatabaseManager(const QString& host, const QString& dbName, const QString& user, const QString& password, const bool &dryMode)
|
||||||
:dryMode(dryMode)
|
:dryMode(dryMode)
|
||||||
{
|
{
|
||||||
db = QSqlDatabase::addDatabase("QPSQL");
|
db = QSqlDatabase::addDatabase("QPSQL");
|
||||||
db.setDatabaseName(dbName);
|
db.setDatabaseName(dbName);
|
||||||
db.setHostName(host);
|
db.setHostName(host);
|
||||||
db.setUserName(user); // home-office stuff -->> db.setPort(80);
|
db.setUserName(user); // home-office stuff -->> db.setPort(80);
|
||||||
db.setPassword(password);
|
db.setPassword(password);
|
||||||
if (!db.open())
|
if (!db.open())
|
||||||
{
|
{
|
||||||
opened = false;
|
opened = false;
|
||||||
Logger::log("Opening error" + db.lastError().text());
|
Logger::log("Opening error" + db.lastError().text());
|
||||||
emit error();
|
emit error();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
opened = true;
|
opened = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add or update subject to db
|
// add or update subject to db
|
||||||
int DatabaseManager::saveSubject(const std::shared_ptr<Subject>& subject, const QString& table)
|
int DatabaseManager::saveSubject(const std::shared_ptr<Subject>& subject, const QString& table)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
QString id = subject->idToStringWithoutBraces();
|
QString id = subject->idToStringWithoutBraces();
|
||||||
int rtn;
|
int rtn;
|
||||||
if (checkIfExists(id, table)){
|
if (checkIfExists(id, table)){
|
||||||
query.prepare(QString("UPDATE %1 SET id = :id, description = :description, last_update = :last_update, name = :name, pin = :pin, last_modified = :last_modified, deleted = :deleted "
|
query.prepare(QString("UPDATE %1 SET id = :id, description = :description, last_update = :last_update, name = :name, pin = :pin, last_modified = :last_modified, deleted = :deleted "
|
||||||
"WHERE id = :id").arg(table));
|
"WHERE id = :id").arg(table));
|
||||||
rtn = -1;
|
rtn = -1;
|
||||||
}else{
|
}else{
|
||||||
query.prepare(QString("INSERT INTO %1 (id, description, last_update, name, pin, last_modified, deleted) "
|
query.prepare(QString("INSERT INTO %1 (id, description, last_update, name, pin, last_modified, deleted) "
|
||||||
"VALUES (:id, :description, :last_update, :name, :pin, :last_modified, :deleted)").arg(table));
|
"VALUES (:id, :description, :last_update, :name, :pin, :last_modified, :deleted)").arg(table));
|
||||||
rtn = 1;
|
rtn = 1;
|
||||||
}
|
}
|
||||||
query.bindValue(":id", id);
|
query.bindValue(":id", id);
|
||||||
query.bindValue(":description", subject->getDescription());
|
query.bindValue(":description", subject->getDescription());
|
||||||
query.bindValue(":name", subject->getName());
|
query.bindValue(":name", subject->getName());
|
||||||
query.bindValue(":last_update", QDateTime::fromMSecsSinceEpoch(subject->getLastUpdate()).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
query.bindValue(":last_update", QDateTime::fromMSecsSinceEpoch(subject->getLastUpdate()).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
||||||
query.bindValue(":pin", subject->getPin());
|
query.bindValue(":pin", subject->getPin());
|
||||||
query.bindValue(":last_modified", QDateTime::fromMSecsSinceEpoch(subject->getLastUpdate()).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
query.bindValue(":last_modified", QDateTime::fromMSecsSinceEpoch(subject->getLastUpdate()).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
||||||
query.bindValue(":deleted", subject->getDeleted());
|
query.bindValue(":deleted", subject->getDeleted());
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add or update token to DB
|
// add or update token to DB
|
||||||
int DatabaseManager::saveToken(const std::shared_ptr<Token>& token, const QString& table)
|
int DatabaseManager::saveToken(const std::shared_ptr<Token>& token, const QString& table)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
QString id = token->idToStringWithoutBraces();
|
QString id = token->idToStringWithoutBraces();
|
||||||
int rtn;
|
int rtn;
|
||||||
if (checkIfExists(id, table)){
|
if (checkIfExists(id, table)){
|
||||||
query.prepare(QString("UPDATE %1 SET id = :id, auth_errors = :auth_errors, description = :description, enabled = :enabled, last_update = :last_update, name = :name, no_validity = :no_validity, time_to_live = :time_to_live, token_bits = :token_bits, token_data = :token_data, token_type = :token_type, subject_id = :subject_id, last_modified = :last_modified, deleted = :deleted "
|
query.prepare(QString("UPDATE %1 SET id = :id, auth_errors = :auth_errors, description = :description, enabled = :enabled, last_update = :last_update, name = :name, no_validity = :no_validity, time_to_live = :time_to_live, token_bits = :token_bits, token_data = :token_data, token_type = :token_type, subject_id = :subject_id, last_modified = :last_modified, deleted = :deleted "
|
||||||
"WHERE id = :id").arg(table));
|
"WHERE id = :id").arg(table));
|
||||||
rtn = -1;
|
rtn = -1;
|
||||||
}else{
|
}else{
|
||||||
query.prepare(QString("INSERT INTO %1 (id, auth_errors, description, enabled, last_update, name, no_validity, time_to_live, token_bits, token_data, token_type, subject_id, last_modified, deleted) "
|
query.prepare(QString("INSERT INTO %1 (id, auth_errors, description, enabled, last_update, name, no_validity, time_to_live, token_bits, token_data, token_type, subject_id, last_modified, deleted) "
|
||||||
"VALUES (:id, :auth_errors, :description, :enabled, :last_update, :name, :no_validity, :time_to_live, :token_bits, :token_data, :token_type, :subject_id, :last_modified, :deleted)").arg(table));
|
"VALUES (:id, :auth_errors, :description, :enabled, :last_update, :name, :no_validity, :time_to_live, :token_bits, :token_data, :token_type, :subject_id, :last_modified, :deleted)").arg(table));
|
||||||
rtn = 1;
|
rtn = 1;
|
||||||
}
|
}
|
||||||
query.bindValue(":id", id);
|
query.bindValue(":id", id);
|
||||||
query.bindValue(":auth_errors", token->getAuthErrors());
|
query.bindValue(":auth_errors", token->getAuthErrors());
|
||||||
query.bindValue(":description", token->getDescription());
|
query.bindValue(":description", token->getDescription());
|
||||||
query.bindValue(":enabled", token->getFlags().contains("Enabled"));
|
query.bindValue(":enabled", token->getFlags().contains("Enabled"));
|
||||||
query.bindValue(":last_update", QDateTime::fromMSecsSinceEpoch(token->getLastUpdate()).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
query.bindValue(":last_update", QDateTime::fromMSecsSinceEpoch(token->getLastUpdate()).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
||||||
query.bindValue(":name", token->getName());
|
query.bindValue(":name", token->getName());
|
||||||
query.bindValue(":no_validity", token->getFlags().contains("NoValidity"));
|
query.bindValue(":no_validity", token->getFlags().contains("NoValidity"));
|
||||||
query.bindValue(":time_to_live", token->getTimeToLive());
|
query.bindValue(":time_to_live", token->getTimeToLive());
|
||||||
query.bindValue(":token_bits", token->getTokenBits());
|
query.bindValue(":token_bits", token->getTokenBits());
|
||||||
query.bindValue(":token_data", token->getTokenData());
|
query.bindValue(":token_data", token->getTokenData());
|
||||||
query.bindValue(":token_type", token->getTokenType());
|
query.bindValue(":token_type", token->getTokenType());
|
||||||
query.bindValue(":subject_id", token->subjectIdToStringWithoutBraces());
|
query.bindValue(":subject_id", token->subjectIdToStringWithoutBraces());
|
||||||
query.bindValue(":last_modified", QDateTime::fromMSecsSinceEpoch(token->getLastUpdate()).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
query.bindValue(":last_modified", QDateTime::fromMSecsSinceEpoch(token->getLastUpdate()).toString("yyyy-MM-dd hh:mm:ss.zzz"));
|
||||||
query.bindValue(":deleted", token->getDeleted());
|
query.bindValue(":deleted", token->getDeleted());
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add of update subject attributes
|
// add of update subject attributes
|
||||||
void DatabaseManager::saveSubjectAttributes(const std::shared_ptr<Subject>& subject, const QString& table)
|
void DatabaseManager::saveSubjectAttributes(const std::shared_ptr<Subject>& subject, const QString& table)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
auto attributes = subject->getAtr();
|
auto attributes = subject->getAtr();
|
||||||
for (const auto& attribute : attributes){
|
for (const auto& attribute : attributes){
|
||||||
QString id = subject->idToStringWithoutBraces() + " " + attribute.first;
|
QString id = subject->idToStringWithoutBraces() + " " + attribute.first;
|
||||||
if (checkIfExists(id, table)){
|
if (checkIfExists(id, table)){
|
||||||
query.prepare(QString("UPDATE %1 SET id = :id, attribute_key = :key, attribute_value = :value, subject_id = :subject_id) "
|
query.prepare(QString("UPDATE %1 SET id = :id, attribute_key = :key, attribute_value = :value, subject_id = :subject_id) "
|
||||||
"WHERE id = :id").arg(table));
|
"WHERE id = :id").arg(table));
|
||||||
}else{
|
}else{
|
||||||
query.prepare(QString("INSERT INTO %1 (id, attribute_key, attribute_value, subject_id)"
|
query.prepare(QString("INSERT INTO %1 (id, attribute_key, attribute_value, subject_id)"
|
||||||
"VALUES (:id, :key, :value, :subject_id)").arg(table));
|
"VALUES (:id, :key, :value, :subject_id)").arg(table));
|
||||||
}
|
}
|
||||||
query.bindValue(":id", id);
|
query.bindValue(":id", id);
|
||||||
query.bindValue(":key", attribute.first);
|
query.bindValue(":key", attribute.first);
|
||||||
query.bindValue(":value", attribute.second);
|
query.bindValue(":value", attribute.second);
|
||||||
query.bindValue(":subject_id", subject->idToStringWithoutBraces());
|
query.bindValue(":subject_id", subject->idToStringWithoutBraces());
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// "delete" tokens from DB -> set deleted true
|
// "delete" tokens from DB -> set deleted true
|
||||||
void DatabaseManager::setDeleted(const QString& id, const QString& table, quint64 time)
|
void DatabaseManager::setDeleted(const QString& id, const QString& table, quint64 time)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
QString nowString = QDateTime::fromMSecsSinceEpoch(time).toString("yyyy-MM-dd hh:mm:ss.zzz");
|
QString nowString = QDateTime::fromMSecsSinceEpoch(time).toString("yyyy-MM-dd hh:mm:ss.zzz");
|
||||||
query.prepare(QString("UPDATE %1 SET deleted = true, last_update = :now, last_modified = :now WHERE id = :id").arg(table));
|
query.prepare(QString("UPDATE %1 SET deleted = true, last_update = :now, last_modified = :now WHERE id = :id").arg(table));
|
||||||
query.bindValue(":id", id);
|
query.bindValue(":id", id);
|
||||||
query.bindValue(":now", nowString);
|
query.bindValue(":now", nowString);
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabaseManager::checkIfExists(const QString& id, const QString& table)
|
bool DatabaseManager::checkIfExists(const QString& id, const QString& table)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare(QString("SELECT EXISTS(SELECT 1 FROM %1 WHERE id = :id)").arg(table));
|
query.prepare(QString("SELECT EXISTS(SELECT 1 FROM %1 WHERE id = :id)").arg(table));
|
||||||
query.bindValue(":id", id);
|
query.bindValue(":id", id);
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
query.first();
|
query.first();
|
||||||
return query.value(0).toBool();
|
return query.value(0).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DatabaseManager::getLastQuery(const QSqlQuery& query) const
|
QString DatabaseManager::getLastQuery(const QSqlQuery& query) const
|
||||||
{
|
{
|
||||||
QString str = query.lastQuery();
|
QString str = query.lastQuery();
|
||||||
QMapIterator<QString, QVariant> it(query.boundValues());
|
QMapIterator<QString, QVariant> it(query.boundValues());
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
it.next();
|
it.next();
|
||||||
str.replace(it.key(),it.value().toString());
|
str.replace(it.key(),it.value().toString());
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabaseManager::executeQuery(QSqlQuery &query, const QString &statement)
|
bool DatabaseManager::executeQuery(QSqlQuery &query, const QString &statement)
|
||||||
{
|
{
|
||||||
if (statement.isEmpty()){
|
if (statement.isEmpty()){
|
||||||
if (dryMode){
|
if (dryMode){
|
||||||
QString sqlStatement = getLastQuery(query);
|
QString sqlStatement = getLastQuery(query);
|
||||||
qDebug() << sqlStatement;
|
qDebug() << sqlStatement;
|
||||||
}
|
}
|
||||||
if (!dryMode || getLastQuery(query).startsWith("SELECT")){
|
if (!dryMode || getLastQuery(query).startsWith("SELECT")){
|
||||||
if (!query.exec()){
|
if (!query.exec()){
|
||||||
QString msg = QString("Source: Database Manager, Error: %1").arg(query.lastError().text());
|
QString msg = QString("Source: Database Manager, Error: %1").arg(query.lastError().text());
|
||||||
Logger::logToDb(QString(msg));
|
Logger::logToDb(QString(msg));
|
||||||
emit error();
|
emit error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (dryMode){
|
if (dryMode){
|
||||||
qDebug() << statement;
|
qDebug() << statement;
|
||||||
}
|
}
|
||||||
if (!dryMode || statement.startsWith("SELECT")){
|
if (!dryMode || statement.startsWith("SELECT")){
|
||||||
if (!query.exec(statement)){
|
if (!query.exec(statement)){
|
||||||
QString msg = QString("Source: Database Manager, Error: %1").arg(query.lastError().text());
|
QString msg = QString("Source: Database Manager, Error: %1").arg(query.lastError().text());
|
||||||
Logger::logToDb(QString(msg));
|
Logger::logToDb(QString(msg));
|
||||||
emit error();
|
emit error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseManager::dropTables()
|
void DatabaseManager::dropTables()
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
|
|
||||||
executeQuery(query, "DROP TABLE IF EXISTS colnod_token, colnod_subject, colnod_subject_attribute");
|
executeQuery(query, "DROP TABLE IF EXISTS colnod_token, colnod_subject, colnod_subject_attribute");
|
||||||
}
|
}
|
||||||
|
|
||||||
// create table after deleting, it is used for full sync
|
// create table after deleting, it is used for full sync
|
||||||
void DatabaseManager::createTables()
|
void DatabaseManager::createTables()
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
|
|
||||||
executeQuery(query, "CREATE TABLE colnod_subject ("
|
executeQuery(query, "CREATE TABLE colnod_subject ("
|
||||||
"id character(36) primary key NOT NULL,"
|
"id character(36) primary key NOT NULL,"
|
||||||
"description character varying(255),"
|
"description character varying(255),"
|
||||||
"last_update timestamp NOT NULL,"
|
"last_update timestamp NOT NULL,"
|
||||||
"name character varying(255),"
|
"name character varying(255),"
|
||||||
"pin character varying(255),"
|
"pin character varying(255),"
|
||||||
"last_modified timestamp,"
|
"last_modified timestamp,"
|
||||||
"deleted BOOLEAN)");
|
"deleted BOOLEAN)");
|
||||||
executeQuery(query, "CREATE TABLE colnod_token ("
|
executeQuery(query, "CREATE TABLE colnod_token ("
|
||||||
"id CHAR(36) primary key NOT NULL,"
|
"id CHAR(36) primary key NOT NULL,"
|
||||||
"auth_errors INTEGER NOT NULL,"
|
"auth_errors INTEGER NOT NULL,"
|
||||||
"description VARCHAR(255),"
|
"description VARCHAR(255),"
|
||||||
"enabled BOOLEAN NOT NULL,"
|
"enabled BOOLEAN NOT NULL,"
|
||||||
"last_update timestamp NOT NULL,"
|
"last_update timestamp NOT NULL,"
|
||||||
"name VARCHAR(255),"
|
"name VARCHAR(255),"
|
||||||
"no_validity BOOLEAN NOT NULL,"
|
"no_validity BOOLEAN NOT NULL,"
|
||||||
"time_to_live INTEGER NOT NULL,"
|
"time_to_live INTEGER NOT NULL,"
|
||||||
"token_bits INTEGER,"
|
"token_bits INTEGER,"
|
||||||
"token_data VARCHAR(255),"
|
"token_data VARCHAR(255),"
|
||||||
"token_type VARCHAR(255),"
|
"token_type VARCHAR(255),"
|
||||||
"subject_id CHAR(36),"
|
"subject_id CHAR(36),"
|
||||||
"last_modified timestamp,"
|
"last_modified timestamp,"
|
||||||
"deleted BOOLEAN)");
|
"deleted BOOLEAN)");
|
||||||
executeQuery(query, "CREATE TABLE colnod_subject_attribute ("
|
executeQuery(query, "CREATE TABLE colnod_subject_attribute ("
|
||||||
"id VARCHAR(255) primary key,"
|
"id VARCHAR(255) primary key,"
|
||||||
"attribute_key VARCHAR(255),"
|
"attribute_key VARCHAR(255),"
|
||||||
"attribute_value VARCHAR(255),"
|
"attribute_value VARCHAR(255),"
|
||||||
"subject_id CHAR(36))");
|
"subject_id CHAR(36))");
|
||||||
}
|
}
|
||||||
|
|
||||||
// return last_sync time
|
// return last_sync time
|
||||||
quint64 DatabaseManager::getLastSync()
|
quint64 DatabaseManager::getLastSync()
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
executeQuery(query, "SELECT last_sync FROM config");
|
executeQuery(query, "SELECT last_sync FROM config");
|
||||||
query.next();
|
query.next();
|
||||||
quint64 temp = query.value(0).toULongLong();
|
quint64 temp = query.value(0).toULongLong();
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// on the very end of sync set new Last_sync time (begin of this sync)
|
// on the very end of sync set new Last_sync time (begin of this sync)
|
||||||
void DatabaseManager::updateLastSync(quint64 lastSync)
|
void DatabaseManager::updateLastSync(quint64 lastSync)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("UPDATE config SET last_sync = :last_sync");
|
query.prepare("UPDATE config SET last_sync = :last_sync");
|
||||||
query.bindValue(":last_sync", lastSync);
|
query.bindValue(":last_sync", lastSync);
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// return set of tokens to update form DB
|
// return set of tokens to update form DB
|
||||||
QSqlQuery DatabaseManager::getUpdatedTokens()
|
QSqlQuery DatabaseManager::getUpdatedTokens()
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
executeQuery(query, "SELECT id, auth_errors, description, enabled, last_update, name, no_validity, time_to_live, token_bits, token_data, token_type, subject_id, last_modified, deleted "
|
executeQuery(query, "SELECT id, auth_errors, description, enabled, last_update, name, no_validity, time_to_live, token_bits, token_data, token_type, subject_id, last_modified, deleted "
|
||||||
"FROM colnod_token WHERE EXTRACT(EPOCH FROM last_modified) * 1000 > EXTRACT(EPOCH FROM last_update) * 1000");
|
"FROM colnod_token WHERE EXTRACT(EPOCH FROM last_modified) * 1000 > EXTRACT(EPOCH FROM last_update) * 1000");
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSqlQuery DatabaseManager::getToken(const QString& id)
|
QSqlQuery DatabaseManager::getToken(const QString& id)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT id, auth_errors, description, enabled, last_update, name, no_validity, time_to_live, token_bits, token_data, token_type, subject_id, last_modified, deleted "
|
query.prepare("SELECT id, auth_errors, description, enabled, last_update, name, no_validity, time_to_live, token_bits, token_data, token_type, subject_id, last_modified, deleted "
|
||||||
"FROM colnod_token WHERE id = :id");
|
"FROM colnod_token WHERE id = :id");
|
||||||
query.bindValue(":id", id);
|
query.bindValue(":id", id);
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
query.next();
|
query.next();
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 DatabaseManager::getNow()
|
quint64 DatabaseManager::getNow()
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
executeQuery(query, "SELECT EXTRACT(EPOCH FROM NOW())*1000");
|
executeQuery(query, "SELECT EXTRACT(EPOCH FROM NOW())*1000");
|
||||||
query.next();
|
query.next();
|
||||||
return query.value(0).toULongLong();
|
return query.value(0).toULongLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync last update back to DB from Colnod after changes made to Colnod
|
// sync last update back to DB from Colnod after changes made to Colnod
|
||||||
void DatabaseManager::setLastUpdate(const QString& id, quint64 lastUpdate)
|
void DatabaseManager::setLastUpdate(const QString& id, quint64 lastUpdate)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
QString lsatUpdateString = QDateTime::fromMSecsSinceEpoch(lastUpdate).toString("yyyy-MM-dd hh:mm:ss.zzz");
|
QString lsatUpdateString = QDateTime::fromMSecsSinceEpoch(lastUpdate).toString("yyyy-MM-dd hh:mm:ss.zzz");
|
||||||
query.prepare("UPDATE colnod_token SET last_update = :last_update WHERE id = :id");
|
query.prepare("UPDATE colnod_token SET last_update = :last_update WHERE id = :id");
|
||||||
query.bindValue(":id", id);
|
query.bindValue(":id", id);
|
||||||
query.bindValue(":last_update", lsatUpdateString);
|
query.bindValue(":last_update", lsatUpdateString);
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseManager::log(const QString &msg)
|
void DatabaseManager::log(const QString &msg)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("INSERT INTO logs (log_time, msg) VALUES (NOW(), :msg)");
|
query.prepare("INSERT INTO logs (log_time, msg) VALUES (NOW(), :msg)");
|
||||||
query.bindValue(":msg", msg);
|
query.bindValue(":msg", msg);
|
||||||
query.exec();
|
query.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DatabaseManager::getSubjectNameByTokenId(const QString &tokenId)
|
QString DatabaseManager::getSubjectNameByTokenId(const QString &tokenId)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT name FROM colnod_subject WHERE id = (SELECT subject_id FROM colnod_token WHERE id = :tokenId)");
|
query.prepare("SELECT name FROM colnod_subject WHERE id = (SELECT subject_id FROM colnod_token WHERE id = :tokenId)");
|
||||||
query.bindValue(":tokenId", tokenId);
|
query.bindValue(":tokenId", tokenId);
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
if (query.next())
|
if (query.next())
|
||||||
return query.value(0).toString();
|
return query.value(0).toString();
|
||||||
qWarning() << "Token:" << tokenId << "is not assigned to any subject";
|
qWarning() << "Token:" << tokenId << "is not assigned to any subject";
|
||||||
return "(No subject)";
|
return "(No subject)";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DatabaseManager::getSubjectNameById(const QString &id)
|
QString DatabaseManager::getSubjectNameById(const QString &id)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT name FROM colnod_subject WHERE id = :id");
|
query.prepare("SELECT name FROM colnod_subject WHERE id = :id");
|
||||||
query.bindValue(":id", id);
|
query.bindValue(":id", id);
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
if (query.next())
|
if (query.next())
|
||||||
return query.value(0).toString();
|
return query.value(0).toString();
|
||||||
qWarning() << "Subject:" << id << "doesn't exists";
|
qWarning() << "Subject:" << id << "doesn't exists";
|
||||||
return "(No subject)";
|
return "(No subject)";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabaseManager::checkDeletedToken(const QString &id)
|
bool DatabaseManager::checkDeletedToken(const QString &id)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT deleted FROM colnod_token WHERE id = :id");
|
query.prepare("SELECT deleted FROM colnod_token WHERE id = :id");
|
||||||
query.bindValue(":id", id);
|
query.bindValue(":id", id);
|
||||||
executeQuery(query);
|
executeQuery(query);
|
||||||
query.next();
|
query.next();
|
||||||
return query.value(0).toBool();
|
return query.value(0).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabaseManager::isOpen()
|
bool DatabaseManager::isOpen()
|
||||||
{
|
{
|
||||||
return opened;
|
return opened;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,59 +1,59 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QSql>
|
#include <QSql>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "subject.h"
|
#include "subject.h"
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
|
|
||||||
class DatabaseManager : public QObject
|
class DatabaseManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DatabaseManager(const QString& host, const QString& dbName, const QString& user, const QString& password, const bool& dryMode = false);
|
DatabaseManager(const QString& host, const QString& dbName, const QString& user, const QString& password, const bool& dryMode = false);
|
||||||
|
|
||||||
int saveSubject(const std::shared_ptr<Subject>& subject, const QString& table);
|
int saveSubject(const std::shared_ptr<Subject>& subject, const QString& table);
|
||||||
int saveToken(const std::shared_ptr<Token>& token, const QString& table);
|
int saveToken(const std::shared_ptr<Token>& token, const QString& table);
|
||||||
void saveSubjectAttributes(const std::shared_ptr<Subject>& subject, const QString& table);
|
void saveSubjectAttributes(const std::shared_ptr<Subject>& subject, const QString& table);
|
||||||
void setDeleted(const QString& id, const QString& table, quint64 time);
|
void setDeleted(const QString& id, const QString& table, quint64 time);
|
||||||
|
|
||||||
void dropTables();
|
void dropTables();
|
||||||
void createTables();
|
void createTables();
|
||||||
|
|
||||||
quint64 getLastSync();
|
quint64 getLastSync();
|
||||||
void updateLastSync(quint64 lastSync);
|
void updateLastSync(quint64 lastSync);
|
||||||
quint64 getNow();
|
quint64 getNow();
|
||||||
|
|
||||||
QSqlQuery getUpdatedTokens();
|
QSqlQuery getUpdatedTokens();
|
||||||
QSqlQuery getToken(const QString& id);
|
QSqlQuery getToken(const QString& id);
|
||||||
|
|
||||||
void setLastUpdate(const QString& id, quint64 lastUpdate);
|
void setLastUpdate(const QString& id, quint64 lastUpdate);
|
||||||
|
|
||||||
void log(const QString &msg);
|
void log(const QString &msg);
|
||||||
QString getSubjectNameByTokenId(const QString &tokenId);
|
QString getSubjectNameByTokenId(const QString &tokenId);
|
||||||
QString getSubjectNameById(const QString &id);
|
QString getSubjectNameById(const QString &id);
|
||||||
bool checkDeletedToken(const QString &id);
|
bool checkDeletedToken(const QString &id);
|
||||||
|
|
||||||
bool isOpen();
|
bool isOpen();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkIfExists(const QString& id, const QString& table);
|
bool checkIfExists(const QString& id, const QString& table);
|
||||||
bool executeQuery(QSqlQuery &query, const QString &statement = QString());
|
bool executeQuery(QSqlQuery &query, const QString &statement = QString());
|
||||||
QString getLastQuery(const QSqlQuery &query) const;
|
QString getLastQuery(const QSqlQuery &query) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error();
|
void error();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSqlDatabase db;
|
QSqlDatabase db;
|
||||||
bool dryMode = false;
|
bool dryMode = false;
|
||||||
bool opened = false;
|
bool opened = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,83 +1,83 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include "subject.h"
|
#include "subject.h"
|
||||||
#include "requestmanager.h"
|
#include "requestmanager.h"
|
||||||
#include "databasemanager.h"
|
#include "databasemanager.h"
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <qjsonarray.h>
|
#include <qjsonarray.h>
|
||||||
#include <logger.h>
|
#include <logger.h>
|
||||||
|
|
||||||
|
|
||||||
class DataManager : public QObject
|
class DataManager : public QObject
|
||||||
{
|
{
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataManager(const bool& dryMode = false);
|
DataManager(const bool& dryMode = false);
|
||||||
|
|
||||||
void fillFullTokensColnod(const QString& jsonResponse);
|
void fillFullTokensColnod(const QString& jsonResponse);
|
||||||
|
|
||||||
void fillTokensToUpdateColnod(const QString& jsonResponse);
|
void fillTokensToUpdateColnod(const QString& jsonResponse);
|
||||||
void fillSubjectsToUpdateColnod(const QString& jsonResponse);
|
void fillSubjectsToUpdateColnod(const QString& jsonResponse);
|
||||||
void fillSubjectsToDeleteColnod(const QString& jsonResponse);
|
void fillSubjectsToDeleteColnod(const QString& jsonResponse);
|
||||||
void fillTokensToDeleteColnod(const QString& jsonResponse);
|
void fillTokensToDeleteColnod(const QString& jsonResponse);
|
||||||
|
|
||||||
void fillTokensToChangeDB();
|
void fillTokensToChangeDB();
|
||||||
void fillSubjectsToUpdateDB();
|
void fillSubjectsToUpdateDB();
|
||||||
void fillSubjectsToDeleteDB();
|
void fillSubjectsToDeleteDB();
|
||||||
|
|
||||||
void filterTokensDB();
|
void filterTokensDB();
|
||||||
void filterTokensColnod();
|
void filterTokensColnod();
|
||||||
|
|
||||||
void pushSubjectsToDB();
|
void pushSubjectsToDB();
|
||||||
void pushTokensToDB();
|
void pushTokensToDB();
|
||||||
void deleteSubjectsFromDB();
|
void deleteSubjectsFromDB();
|
||||||
void setDeletedToTokensFromDB();
|
void setDeletedToTokensFromDB();
|
||||||
|
|
||||||
void updateLastSync();
|
void updateLastSync();
|
||||||
|
|
||||||
void emptyDatabase();
|
void emptyDatabase();
|
||||||
|
|
||||||
quint64 getLastModifiedOfToken(const QString &id);
|
quint64 getLastModifiedOfToken(const QString &id);
|
||||||
|
|
||||||
QHash<QString, std::shared_ptr<Token>> getTokensToUpdateFromColnod() {return tokensToUpdateFromColnodToDB;}
|
QHash<QString, std::shared_ptr<Token>> getTokensToUpdateFromColnod() {return tokensToUpdateFromColnodToDB;}
|
||||||
QList<QString> getTokensToDeleteColnod() {return tokensFromColnodToDeleteFromDB;}
|
QList<QString> getTokensToDeleteColnod() {return tokensFromColnodToDeleteFromDB;}
|
||||||
QHash<QString, std::shared_ptr<Token>> getTokensToUpdateFromDB() {return tokensToUpdateFromDBToColnod;}
|
QHash<QString, std::shared_ptr<Token>> getTokensToUpdateFromDB() {return tokensToUpdateFromDBToColnod;}
|
||||||
QList<QString> getTokensToDeleteDB() {return tokensFromDBToDeleteFromColnod;}
|
QList<QString> getTokensToDeleteDB() {return tokensFromDBToDeleteFromColnod;}
|
||||||
|
|
||||||
const quint64 &getLastSync() {return lastSync;}
|
const quint64 &getLastSync() {return lastSync;}
|
||||||
const quint64 &getCurrentSync() {return nextLastSync;}
|
const quint64 &getCurrentSync() {return nextLastSync;}
|
||||||
|
|
||||||
bool isDBOpened() {return db->isOpen();}
|
bool isDBOpened() {return db->isOpen();}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clear();
|
void clear();
|
||||||
void setLastUpdate();
|
void setLastUpdate();
|
||||||
void setLastUpdate(const QString &id);
|
void setLastUpdate(const QString &id);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error();
|
void error();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<DatabaseManager> db;
|
std::shared_ptr<DatabaseManager> db;
|
||||||
|
|
||||||
quint64 lastSync; // time of last run
|
quint64 lastSync; // time of last run
|
||||||
quint64 nextLastSync; // time of begin of this run
|
quint64 nextLastSync; // time of begin of this run
|
||||||
|
|
||||||
QHash<QString, std::shared_ptr<Token>> allTokensFromColnodById;
|
QHash<QString, std::shared_ptr<Token>> allTokensFromColnodById;
|
||||||
QHash<QString, std::shared_ptr<Token>> allTokensFromColnodByName;
|
QHash<QString, std::shared_ptr<Token>> allTokensFromColnodByName;
|
||||||
QHash<QString, std::shared_ptr<Subject>> subjectsToUpdateFromColnodToDB;
|
QHash<QString, std::shared_ptr<Subject>> subjectsToUpdateFromColnodToDB;
|
||||||
QHash<QString, std::shared_ptr<Token>> tokensToUpdateFromColnodToDB;
|
QHash<QString, std::shared_ptr<Token>> tokensToUpdateFromColnodToDB;
|
||||||
QHash<QString, std::shared_ptr<Subject>> subjectsDB; // in future
|
QHash<QString, std::shared_ptr<Subject>> subjectsDB; // in future
|
||||||
QHash<QString, std::shared_ptr<Token>> tokensToUpdateFromDBToColnod;
|
QHash<QString, std::shared_ptr<Token>> tokensToUpdateFromDBToColnod;
|
||||||
|
|
||||||
QList<QString> subjectsFromColnodToDeleteFromDB;
|
QList<QString> subjectsFromColnodToDeleteFromDB;
|
||||||
QList<QString> tokensFromColnodToDeleteFromDB;
|
QList<QString> tokensFromColnodToDeleteFromDB;
|
||||||
QList<QString> subjectsToDeleteDB;
|
QList<QString> subjectsToDeleteDB;
|
||||||
QList<QString> tokensFromDBToDeleteFromColnod;
|
QList<QString> tokensFromDBToDeleteFromColnod;
|
||||||
|
|
||||||
bool dryMode = false;
|
bool dryMode = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,76 +1,76 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
|
|
||||||
const QUuid &Entity::getId() const {
|
const QUuid &Entity::getId() const {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setId(const QUuid &id) {
|
void Entity::setId(const QUuid &id) {
|
||||||
Entity::id = id;
|
Entity::id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Entity::getName() const {
|
const QString &Entity::getName() const {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setName(const QString &name) {
|
void Entity::setName(const QString &name) {
|
||||||
Entity::name = name;
|
Entity::name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Entity::getDescription() const {
|
const QString &Entity::getDescription() const {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setDescription(const QString &description) {
|
void Entity::setDescription(const QString &description) {
|
||||||
Entity::description = description;
|
Entity::description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 Entity::getLastUpdate() const {
|
quint64 Entity::getLastUpdate() const {
|
||||||
return lastUpdate;
|
return lastUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setLastUpdate(quint64 lastUpdate) {
|
void Entity::setLastUpdate(quint64 lastUpdate) {
|
||||||
this->lastUpdate = lastUpdate;
|
this->lastUpdate = lastUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 Entity::getLastModified() const {
|
quint64 Entity::getLastModified() const {
|
||||||
return lastModified;
|
return lastModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setLastModified(const quint64 &lastModified) {
|
void Entity::setLastModified(const quint64 &lastModified) {
|
||||||
this->lastModified = lastModified;
|
this->lastModified = lastModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::getDeleted() const
|
bool Entity::getDeleted() const
|
||||||
{
|
{
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setDeleted(const bool &deleted)
|
void Entity::setDeleted(const bool &deleted)
|
||||||
{
|
{
|
||||||
this->deleted = deleted;
|
this->deleted = deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Entity::idToStringWithoutBraces() const
|
QString Entity::idToStringWithoutBraces() const
|
||||||
{
|
{
|
||||||
const qint8 lengthOfUuid = 36;
|
const qint8 lengthOfUuid = 36;
|
||||||
return id.toString().mid(1, lengthOfUuid);
|
return id.toString().mid(1, lengthOfUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::fromJSON(const QJsonObject &json) {
|
void Entity::fromJSON(const QJsonObject &json) {
|
||||||
id = json["id"].toString();
|
id = json["id"].toString();
|
||||||
name = json["name"].toString();
|
name = json["name"].toString();
|
||||||
description = json["description"].toString();
|
description = json["description"].toString();
|
||||||
lastUpdate = json["lastUpdate"].toDouble();
|
lastUpdate = json["lastUpdate"].toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject Entity::toJSON() const {
|
QJsonObject Entity::toJSON() const {
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
|
||||||
json["id"] = this->idToStringWithoutBraces();
|
json["id"] = this->idToStringWithoutBraces();
|
||||||
json["name"] = name;
|
json["name"] = name;
|
||||||
json["description"] = description;
|
json["description"] = description;
|
||||||
json["lastUpdate"] = lastUpdate;
|
json["lastUpdate"] = lastUpdate;
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,47 +1,47 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
#include <QtCore/QJsonObject>
|
#include <QtCore/QJsonObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
class Entity : public QObject {
|
class Entity : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
using QObject::QObject;
|
using QObject::QObject;
|
||||||
|
|
||||||
const QUuid &getId() const;
|
const QUuid &getId() const;
|
||||||
void setId(const QUuid &id);
|
void setId(const QUuid &id);
|
||||||
|
|
||||||
const QString &getName() const;
|
const QString &getName() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
const QString &getDescription() const;
|
const QString &getDescription() const;
|
||||||
void setDescription(const QString &description);
|
void setDescription(const QString &description);
|
||||||
|
|
||||||
quint64 getLastUpdate() const;
|
quint64 getLastUpdate() const;
|
||||||
void setLastUpdate(quint64 lastUpdate);
|
void setLastUpdate(quint64 lastUpdate);
|
||||||
|
|
||||||
quint64 getLastModified() const;
|
quint64 getLastModified() const;
|
||||||
void setLastModified(const quint64 &lastModified);
|
void setLastModified(const quint64 &lastModified);
|
||||||
|
|
||||||
bool getDeleted() const;
|
bool getDeleted() const;
|
||||||
void setDeleted(const bool &deleted);
|
void setDeleted(const bool &deleted);
|
||||||
|
|
||||||
QString idToStringWithoutBraces() const;
|
QString idToStringWithoutBraces() const;
|
||||||
|
|
||||||
virtual void fromJSON(const QJsonObject &json);
|
virtual void fromJSON(const QJsonObject &json);
|
||||||
virtual QJsonObject toJSON() const;
|
virtual QJsonObject toJSON() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUuid id;
|
QUuid id;
|
||||||
QString name;
|
QString name;
|
||||||
QString description;
|
QString description;
|
||||||
qint64 lastUpdate{};
|
qint64 lastUpdate{};
|
||||||
quint64 lastModified{};
|
quint64 lastModified{};
|
||||||
bool deleted{};
|
bool deleted{};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,54 +1,54 @@
|
|||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "databasemanager.h"
|
#include "databasemanager.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
std::shared_ptr<DatabaseManager> Logger::dbMan = nullptr;
|
std::shared_ptr<DatabaseManager> Logger::dbMan = nullptr;
|
||||||
Logger *Logger::logger = nullptr;
|
Logger *Logger::logger = nullptr;
|
||||||
|
|
||||||
Logger::Logger()
|
Logger::Logger()
|
||||||
{
|
{
|
||||||
dbMan = nullptr;
|
dbMan = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger *Logger::getLogger()
|
Logger *Logger::getLogger()
|
||||||
{
|
{
|
||||||
if (!logger)
|
if (!logger)
|
||||||
logger = new Logger;
|
logger = new Logger;
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::log(const QString& msg)
|
void Logger::log(const QString& msg)
|
||||||
{
|
{
|
||||||
qDebug() << msg;
|
qDebug() << msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::logToDb(const QString &msg)
|
void Logger::logToDb(const QString &msg)
|
||||||
{
|
{
|
||||||
if (dbMan)
|
if (dbMan)
|
||||||
Logger::dbMan->log(msg);
|
Logger::dbMan->log(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::setDBMan(std::shared_ptr<DatabaseManager> dbMan)
|
void Logger::setDBMan(std::shared_ptr<DatabaseManager> dbMan)
|
||||||
{
|
{
|
||||||
Logger::dbMan = std::move(dbMan);
|
Logger::dbMan = std::move(dbMan);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Logger::makeTokenMsg(const QString &tokenId, const QString &action, const QString &source)
|
QString Logger::makeTokenMsg(const QString &tokenId, const QString &action, const QString &source)
|
||||||
{
|
{
|
||||||
return QString("Token: %1 of subject: %2 %3. Source: %4").arg(tokenId,dbMan->getSubjectNameByTokenId(tokenId), action, source);
|
return QString("Token: %1 of subject: %2 %3. Source: %4").arg(tokenId,dbMan->getSubjectNameByTokenId(tokenId), action, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Logger::makeSubjectMsg(const QString &subjectId, const QString &action, const QString &source)
|
QString Logger::makeSubjectMsg(const QString &subjectId, const QString &action, const QString &source)
|
||||||
{
|
{
|
||||||
return QString("Subject: %1 %2. Source: %3").arg(dbMan->getSubjectNameById(subjectId), action, source);
|
return QString("Subject: %1 %2. Source: %3").arg(dbMan->getSubjectNameById(subjectId), action, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Logger::makeErrorMsg(const QString &source, const QString &errMsg)
|
QString Logger::makeErrorMsg(const QString &source, const QString &errMsg)
|
||||||
{
|
{
|
||||||
return QString("Source: %1, Error: %2").arg(source, errMsg);
|
return QString("Source: %1, Error: %2").arg(source, errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,33 +1,33 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class DatabaseManager;
|
class DatabaseManager;
|
||||||
|
|
||||||
|
|
||||||
class Logger
|
class Logger
|
||||||
{
|
{
|
||||||
|
|
||||||
static Logger *logger;
|
static Logger *logger;
|
||||||
|
|
||||||
Logger();
|
Logger();
|
||||||
|
|
||||||
static std::shared_ptr<DatabaseManager> dbMan;
|
static std::shared_ptr<DatabaseManager> dbMan;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Logger *getLogger();
|
static Logger *getLogger();
|
||||||
static void log(const QString& msg);
|
static void log(const QString& msg);
|
||||||
static void logToDb(const QString& msg);
|
static void logToDb(const QString& msg);
|
||||||
static void setDBMan(std::shared_ptr<DatabaseManager> dbMan);
|
static void setDBMan(std::shared_ptr<DatabaseManager> dbMan);
|
||||||
static QString makeTokenMsg(const QString& tokenId, const QString& action, const QString& source);
|
static QString makeTokenMsg(const QString& tokenId, const QString& action, const QString& source);
|
||||||
static QString makeSubjectMsg(const QString& subjectId, const QString& action, const QString& source);
|
static QString makeSubjectMsg(const QString& subjectId, const QString& action, const QString& source);
|
||||||
static QString makeErrorMsg(const QString& source, const QString& errMsg);
|
static QString makeErrorMsg(const QString& source, const QString& errMsg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,247 +1,247 @@
|
|||||||
#include "requestmanager.h"
|
#include "requestmanager.h"
|
||||||
|
|
||||||
RequestManager::RequestManager()
|
RequestManager::RequestManager()
|
||||||
{
|
{
|
||||||
manager = std::make_unique<QNetworkAccessManager>();
|
manager = std::make_unique<QNetworkAccessManager>();
|
||||||
connect(manager.get(), &QNetworkAccessManager::sslErrors, this, &RequestManager::onSSLError);
|
connect(manager.get(), &QNetworkAccessManager::sslErrors, this, &RequestManager::onSSLError);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Response> RequestManager::login()
|
std::shared_ptr<Response> RequestManager::login()
|
||||||
{
|
{
|
||||||
Q_ASSERT(!loginResponse);
|
Q_ASSERT(!loginResponse);
|
||||||
loginResponse = std::make_shared<Response>();
|
loginResponse = std::make_shared<Response>();
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
QString hash = encryptedPassword(this->password);
|
QString hash = encryptedPassword(this->password);
|
||||||
authHeader = getLoginHeader(this->user, hash);
|
authHeader = getLoginHeader(this->user, hash);
|
||||||
QJsonObject reqBody = {
|
QJsonObject reqBody = {
|
||||||
{"password", hash},
|
{"password", hash},
|
||||||
{"username", this->user}
|
{"username", this->user}
|
||||||
};
|
};
|
||||||
request.setUrl(this->host + "/AaaManager/authSession");
|
request.setUrl(this->host + "/AaaManager/authSession");
|
||||||
request.setRawHeader("Authorization", authHeader.toLocal8Bit());
|
request.setRawHeader("Authorization", authHeader.toLocal8Bit());
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json; charset=UTF-8");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json; charset=UTF-8");
|
||||||
QJsonDocument jsonDocument;
|
QJsonDocument jsonDocument;
|
||||||
jsonDocument.setObject(reqBody);
|
jsonDocument.setObject(reqBody);
|
||||||
QNetworkReply* reply = manager->post(request, jsonDocument.toJson());
|
QNetworkReply* reply = manager->post(request, jsonDocument.toJson());
|
||||||
loginResponse->setReply(reply);
|
loginResponse->setReply(reply);
|
||||||
connect(reply, &QNetworkReply::finished, [=]() {
|
connect(reply, &QNetworkReply::finished, [=]() {
|
||||||
if (reply->error())
|
if (reply->error())
|
||||||
{
|
{
|
||||||
Logger::logToDb(Logger::makeErrorMsg("Request Manager", reply->errorString()));
|
Logger::logToDb(Logger::makeErrorMsg("Request Manager", reply->errorString()));
|
||||||
loginStatus = false;
|
loginStatus = false;
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
emit error();
|
emit error();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
loginStatus = true;
|
loginStatus = true;
|
||||||
emit successLogin();
|
emit successLogin();
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
connect(this, &RequestManager::successLogin, loginResponse.get(), &Response::ready);
|
connect(this, &RequestManager::successLogin, loginResponse.get(), &Response::ready);
|
||||||
connect(this, &RequestManager::successLogin, this, &RequestManager::prepareAuthHeader);
|
connect(this, &RequestManager::successLogin, this, &RequestManager::prepareAuthHeader);
|
||||||
return loginResponse;
|
return loginResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkReply* RequestManager::postRequest(const QString& endpoint, const QByteArray& json)
|
QNetworkReply* RequestManager::postRequest(const QString& endpoint, const QByteArray& json)
|
||||||
{
|
{
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
request.setUrl(host + endpoint);
|
request.setUrl(host + endpoint);
|
||||||
request.setRawHeader("Authorization", authHeader.toLocal8Bit());
|
request.setRawHeader("Authorization", authHeader.toLocal8Bit());
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json; charset=UTF-8");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json; charset=UTF-8");
|
||||||
QNetworkReply* reply = manager->post(request, json);
|
QNetworkReply* reply = manager->post(request, json);
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [=]() {
|
QObject::connect(reply, &QNetworkReply::finished, [=]() {
|
||||||
if (reply->error())
|
if (reply->error())
|
||||||
{
|
{
|
||||||
Logger::logToDb(Logger::makeErrorMsg("Request Manager", reply->errorString()));
|
Logger::logToDb(Logger::makeErrorMsg("Request Manager", reply->errorString()));
|
||||||
loginStatus = false;
|
loginStatus = false;
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
emit error();
|
emit error();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emit responseReady();
|
emit responseReady();
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will ensure login is called only once
|
// This will ensure login is called only once
|
||||||
std::shared_ptr<Response> RequestManager::getLoginResponse() {
|
std::shared_ptr<Response> RequestManager::getLoginResponse() {
|
||||||
if (!loginResponse){
|
if (!loginResponse){
|
||||||
loginResponse = login();
|
loginResponse = login();
|
||||||
}
|
}
|
||||||
return loginResponse;
|
return loginResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::postRequestReturnLogic(const QString& endpoint, const QByteArray& data)
|
Response* RequestManager::postRequestReturnLogic(const QString& endpoint, const QByteArray& data)
|
||||||
{
|
{
|
||||||
auto loginResponse = getLoginResponse();
|
auto loginResponse = getLoginResponse();
|
||||||
Q_ASSERT(loginResponse);
|
Q_ASSERT(loginResponse);
|
||||||
auto response = new Response;
|
auto response = new Response;
|
||||||
|
|
||||||
if (!loginStatus){
|
if (!loginStatus){
|
||||||
connect(this, &RequestManager::successLogin, [=](){
|
connect(this, &RequestManager::successLogin, [=](){
|
||||||
response->setReply(postRequest(endpoint, data));
|
response->setReply(postRequest(endpoint, data));
|
||||||
connect(response->getReply(), &QNetworkReply::finished, response, &Response::ready);
|
connect(response->getReply(), &QNetworkReply::finished, response, &Response::ready);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
response->setReply(postRequest(endpoint, data));
|
response->setReply(postRequest(endpoint, data));
|
||||||
connect(response->getReply(), &QNetworkReply::finished, response, &Response::ready);
|
connect(response->getReply(), &QNetworkReply::finished, response, &Response::ready);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get value of member in json
|
// get value of member in json
|
||||||
QString RequestManager::getFromJson(const QString& json, const QString &member)
|
QString RequestManager::getFromJson(const QString& json, const QString &member)
|
||||||
{
|
{
|
||||||
QJsonParseError err{};
|
QJsonParseError err{};
|
||||||
QJsonDocument document = QJsonDocument::fromJson(json.toUtf8(),&err);
|
QJsonDocument document = QJsonDocument::fromJson(json.toUtf8(),&err);
|
||||||
if (err.error != 0)
|
if (err.error != 0)
|
||||||
{
|
{
|
||||||
qDebug() << err.errorString();
|
qDebug() << err.errorString();
|
||||||
}
|
}
|
||||||
return document.object().value(member).toString();
|
return document.object().value(member).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RequestManager::encryptedPassword(const QString& password)
|
QString RequestManager::encryptedPassword(const QString& password)
|
||||||
{
|
{
|
||||||
return QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha512).toHex().toUpper();
|
return QCryptographicHash::hash(password.toLocal8Bit(), QCryptographicHash::Sha512).toHex().toUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RequestManager::getLoginHeader(const QString& username, const QString& hash)
|
QString RequestManager::getLoginHeader(const QString& username, const QString& hash)
|
||||||
{
|
{
|
||||||
QString authValue = username + ":" + hash;
|
QString authValue = username + ":" + hash;
|
||||||
return "Basic " + authValue.toLocal8Bit().toBase64();
|
return "Basic " + authValue.toLocal8Bit().toBase64();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestManager::prepareAuthHeader()
|
void RequestManager::prepareAuthHeader()
|
||||||
{
|
{
|
||||||
jsonResponse = loginResponse->getJson();
|
jsonResponse = loginResponse->getJson();
|
||||||
QString token = getFromJson(jsonResponse, "id");
|
QString token = getFromJson(jsonResponse, "id");
|
||||||
QString authValue = token + ":";
|
QString authValue = token + ":";
|
||||||
authHeader = "Basic " + authValue.toLocal8Bit().toBase64();
|
authHeader = "Basic " + authValue.toLocal8Bit().toBase64();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestManager::onSSLError(QNetworkReply *reply, const QList<QSslError> &errors)
|
void RequestManager::onSSLError(QNetworkReply *reply, const QList<QSslError> &errors)
|
||||||
{
|
{
|
||||||
//qDebug() << "Network SSL errors";
|
//qDebug() << "Network SSL errors";
|
||||||
for (const auto &error : errors)
|
for (const auto &error : errors)
|
||||||
{
|
{
|
||||||
if (error.error() == QSslError::SelfSignedCertificate)
|
if (error.error() == QSslError::SelfSignedCertificate)
|
||||||
reply->ignoreSslErrors(errors);
|
reply->ignoreSslErrors(errors);
|
||||||
//qDebug() << error.errorString();
|
//qDebug() << error.errorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray RequestManager::makeTimestampJson(uint64_t time)
|
QByteArray RequestManager::makeTimestampJson(uint64_t time)
|
||||||
{
|
{
|
||||||
QJsonObject reqBody = {{"timestamp",QJsonValue(static_cast<qint64>(time)) }};
|
QJsonObject reqBody = {{"timestamp",QJsonValue(static_cast<qint64>(time)) }};
|
||||||
QJsonDocument doc;
|
QJsonDocument doc;
|
||||||
doc.setObject(reqBody);
|
doc.setObject(reqBody);
|
||||||
return doc.toJson();
|
return doc.toJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray RequestManager::makeTokensJson(const QHash<QString, std::shared_ptr<Token>> &tokens)
|
QByteArray RequestManager::makeTokensJson(const QHash<QString, std::shared_ptr<Token>> &tokens)
|
||||||
{
|
{
|
||||||
QJsonObject items;
|
QJsonObject items;
|
||||||
QJsonArray jsonTokens;
|
QJsonArray jsonTokens;
|
||||||
for (const auto& token : tokens)
|
for (const auto& token : tokens)
|
||||||
{
|
{
|
||||||
jsonTokens.push_back(token->toJSON());
|
jsonTokens.push_back(token->toJSON());
|
||||||
}
|
}
|
||||||
items.insert("items", jsonTokens);
|
items.insert("items", jsonTokens);
|
||||||
QJsonDocument doc;
|
QJsonDocument doc;
|
||||||
doc.setObject(items);
|
doc.setObject(items);
|
||||||
return doc.toJson();
|
return doc.toJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray RequestManager::makeIdsJson(const QList<QString> &ids)
|
QByteArray RequestManager::makeIdsJson(const QList<QString> &ids)
|
||||||
{
|
{
|
||||||
QJsonArray jsonIds;
|
QJsonArray jsonIds;
|
||||||
for (const auto& id : ids)
|
for (const auto& id : ids)
|
||||||
{
|
{
|
||||||
jsonIds.push_back(id);
|
jsonIds.push_back(id);
|
||||||
}
|
}
|
||||||
QJsonObject items;
|
QJsonObject items;
|
||||||
items.insert("items", jsonIds);
|
items.insert("items", jsonIds);
|
||||||
QJsonDocument doc;
|
QJsonDocument doc;
|
||||||
doc.setObject(items);
|
doc.setObject(items);
|
||||||
return doc.toJson();
|
return doc.toJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getSubjects()
|
Response* RequestManager::getSubjects()
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/SubjectManager/getSubjects");
|
return postRequestReturnLogic("/SubjectManager/getSubjects");
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getTokens()
|
Response* RequestManager::getTokens()
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/TokenManager/getTokens");
|
return postRequestReturnLogic("/TokenManager/getTokens");
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getTokenSubject()
|
Response* RequestManager::getTokenSubject()
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/OpenManager/getTokenSubject");
|
return postRequestReturnLogic("/OpenManager/getTokenSubject");
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getSubjectsUpdated(uint64_t time)
|
Response* RequestManager::getSubjectsUpdated(uint64_t time)
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/SubjectManager/getSubjectsUpdated", makeTimestampJson(time));
|
return postRequestReturnLogic("/SubjectManager/getSubjectsUpdated", makeTimestampJson(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getSubjectsDeleted(uint64_t time)
|
Response* RequestManager::getSubjectsDeleted(uint64_t time)
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/SubjectManager/getSubjectsDeleted", makeTimestampJson(time));
|
return postRequestReturnLogic("/SubjectManager/getSubjectsDeleted", makeTimestampJson(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getTokensUpdated(uint64_t time)
|
Response* RequestManager::getTokensUpdated(uint64_t time)
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/TokenManager/getTokensUpdated", makeTimestampJson(time));
|
return postRequestReturnLogic("/TokenManager/getTokensUpdated", makeTimestampJson(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getTokensDeleted(uint64_t time)
|
Response* RequestManager::getTokensDeleted(uint64_t time)
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/TokenManager/getTokensDeleted", makeTimestampJson(time));
|
return postRequestReturnLogic("/TokenManager/getTokensDeleted", makeTimestampJson(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getAccessGroups()
|
Response* RequestManager::getAccessGroups()
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/AccessManager/getAccessGroups");
|
return postRequestReturnLogic("/AccessManager/getAccessGroups");
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getAccessGroupsUpdated(uint64_t time)
|
Response* RequestManager::getAccessGroupsUpdated(uint64_t time)
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/AccessManager/getAccessGroupsUpdated", makeTimestampJson(time));
|
return postRequestReturnLogic("/AccessManager/getAccessGroupsUpdated", makeTimestampJson(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getAccessGroupsDeleted(uint64_t time)
|
Response* RequestManager::getAccessGroupsDeleted(uint64_t time)
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/AccessManager/getAccessGroupsDeleted", makeTimestampJson(time));
|
return postRequestReturnLogic("/AccessManager/getAccessGroupsDeleted", makeTimestampJson(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getAccessGroupMembership()
|
Response* RequestManager::getAccessGroupMembership()
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/AccessManager/getAccessGroupMembership");
|
return postRequestReturnLogic("/AccessManager/getAccessGroupMembership");
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getAccessGroupMembershipUpdated(uint64_t time)
|
Response* RequestManager::getAccessGroupMembershipUpdated(uint64_t time)
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/AccessManager/getAccessGroupMembershipUpdated", makeTimestampJson(time));
|
return postRequestReturnLogic("/AccessManager/getAccessGroupMembershipUpdated", makeTimestampJson(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::getAccessGroupMembershipDeleted(uint64_t time)
|
Response* RequestManager::getAccessGroupMembershipDeleted(uint64_t time)
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/AccessManager/getAccessGroupMembershipDeleted", makeTimestampJson(time));
|
return postRequestReturnLogic("/AccessManager/getAccessGroupMembershipDeleted", makeTimestampJson(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::setTokens(const QHash<QString, std::shared_ptr<Token>> &tokens)
|
Response* RequestManager::setTokens(const QHash<QString, std::shared_ptr<Token>> &tokens)
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/TokenManager/setTokens", makeTokensJson(tokens));
|
return postRequestReturnLogic("/TokenManager/setTokens", makeTokensJson(tokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
Response* RequestManager::deleteTokens(const QList<QString> &ids)
|
Response* RequestManager::deleteTokens(const QList<QString> &ids)
|
||||||
{
|
{
|
||||||
return postRequestReturnLogic("/TokenManager/deleteTokens", makeIdsJson(ids));
|
return postRequestReturnLogic("/TokenManager/deleteTokens", makeIdsJson(ids));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,100 +1,100 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <qcoreapplication.h>
|
#include <qcoreapplication.h>
|
||||||
#include <qnetworkreply.h>
|
#include <qnetworkreply.h>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QMultiMap>
|
#include <QMultiMap>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QSslError>
|
#include <QSslError>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
|
||||||
|
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include "response.h"
|
#include "response.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
class RequestManager : public QObject
|
class RequestManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class UnitTest;
|
friend class UnitTest;
|
||||||
friend class ComplexTest;
|
friend class ComplexTest;
|
||||||
|
|
||||||
RequestManager();
|
RequestManager();
|
||||||
|
|
||||||
// this should be in ColnodAPI class BEGIN
|
// this should be in ColnodAPI class BEGIN
|
||||||
Response* getSubjects();
|
Response* getSubjects();
|
||||||
Response* getTokens();
|
Response* getTokens();
|
||||||
Response* getTokenSubject();
|
Response* getTokenSubject();
|
||||||
|
|
||||||
Response* getSubjectsUpdated(uint64_t time);
|
Response* getSubjectsUpdated(uint64_t time);
|
||||||
Response* getSubjectsDeleted(uint64_t time);
|
Response* getSubjectsDeleted(uint64_t time);
|
||||||
|
|
||||||
Response* getTokensUpdated(uint64_t time);
|
Response* getTokensUpdated(uint64_t time);
|
||||||
Response* getTokensDeleted(uint64_t time);
|
Response* getTokensDeleted(uint64_t time);
|
||||||
|
|
||||||
Response* getAccessGroups();
|
Response* getAccessGroups();
|
||||||
Response* getAccessGroupsUpdated(uint64_t time);
|
Response* getAccessGroupsUpdated(uint64_t time);
|
||||||
Response* getAccessGroupsDeleted(uint64_t time);
|
Response* getAccessGroupsDeleted(uint64_t time);
|
||||||
Response* getAccessGroupMembership();
|
Response* getAccessGroupMembership();
|
||||||
Response* getAccessGroupMembershipUpdated(uint64_t time);
|
Response* getAccessGroupMembershipUpdated(uint64_t time);
|
||||||
Response* getAccessGroupMembershipDeleted(uint64_t time);
|
Response* getAccessGroupMembershipDeleted(uint64_t time);
|
||||||
|
|
||||||
Response* setTokens(const QHash<QString, std::shared_ptr<Token>> &tokens);
|
Response* setTokens(const QHash<QString, std::shared_ptr<Token>> &tokens);
|
||||||
Response* deleteTokens(const QList<QString> &ids);
|
Response* deleteTokens(const QList<QString> &ids);
|
||||||
// END
|
// END
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// should be public
|
// should be public
|
||||||
QNetworkReply* postRequest(const QString& endpoint, const QByteArray& json = QByteArray());
|
QNetworkReply* postRequest(const QString& endpoint, const QByteArray& json = QByteArray());
|
||||||
Response* postRequestReturnLogic(const QString& endpoint, const QByteArray& data = QByteArray());
|
Response* postRequestReturnLogic(const QString& endpoint, const QByteArray& data = QByteArray());
|
||||||
|
|
||||||
std::shared_ptr<Response> login();
|
std::shared_ptr<Response> login();
|
||||||
std::shared_ptr<Response> getLoginResponse();
|
std::shared_ptr<Response> getLoginResponse();
|
||||||
QString getFromJson(const QString& json, const QString &member);
|
QString getFromJson(const QString& json, const QString &member);
|
||||||
QString encryptedPassword(const QString& password);
|
QString encryptedPassword(const QString& password);
|
||||||
QString getLoginHeader(const QString& username, const QString& hash);
|
QString getLoginHeader(const QString& username, const QString& hash);
|
||||||
|
|
||||||
// in colnod api as well
|
// in colnod api as well
|
||||||
QByteArray makeTimestampJson(uint64_t time);
|
QByteArray makeTimestampJson(uint64_t time);
|
||||||
QByteArray makeTokensJson(const QHash<QString, std::shared_ptr<Token>> &tokens); // maybe better to be in Token class
|
QByteArray makeTokensJson(const QHash<QString, std::shared_ptr<Token>> &tokens); // maybe better to be in Token class
|
||||||
QByteArray makeIdsJson(const QList<QString> &ids); // Entity class
|
QByteArray makeIdsJson(const QList<QString> &ids); // Entity class
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSSLError(QNetworkReply *reply, const QList<QSslError> &errors);
|
void onSSLError(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||||
//void onReplyFinished(QNetworkReply *reply);
|
//void onReplyFinished(QNetworkReply *reply);
|
||||||
void prepareAuthHeader();
|
void prepareAuthHeader();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void successLogin();
|
void successLogin();
|
||||||
void responseReady();
|
void responseReady();
|
||||||
void error();
|
void error();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<QNetworkAccessManager> manager;
|
std::unique_ptr<QNetworkAccessManager> manager;
|
||||||
std::shared_ptr<Response> loginResponse;
|
std::shared_ptr<Response> loginResponse;
|
||||||
QJsonDocument config;
|
QJsonDocument config;
|
||||||
QString authHeader;
|
QString authHeader;
|
||||||
const QString host = "https://192.168.1.3:8443";
|
const QString host = "https://192.168.1.3:8443";
|
||||||
//QString host = "https://localhost:8080";
|
//QString host = "https://localhost:8080";
|
||||||
|
|
||||||
const QString password = "spaceti1";
|
const QString password = "spaceti1";
|
||||||
const QString user = "spaceti";
|
const QString user = "spaceti";
|
||||||
QString jsonResponse;
|
QString jsonResponse;
|
||||||
bool loginStatus = false;
|
bool loginStatus = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
#include "response.h"
|
#include "response.h"
|
||||||
|
|
||||||
Response::Response()
|
Response::Response()
|
||||||
{
|
{
|
||||||
connect(this, &Response::ready, this, &Response::setJson);
|
connect(this, &Response::ready, this, &Response::setJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Response::getStatusCode()
|
int Response::getStatusCode()
|
||||||
{
|
{
|
||||||
return reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
return reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +1,32 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <qnetworkreply.h>
|
#include <qnetworkreply.h>
|
||||||
|
|
||||||
class Response : public QObject
|
class Response : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Response();
|
Response();
|
||||||
|
|
||||||
int getStatusCode();
|
int getStatusCode();
|
||||||
QString getJson() {return json;}
|
QString getJson() {return json;}
|
||||||
void setReply(QNetworkReply* rpl) {reply = rpl;}
|
void setReply(QNetworkReply* rpl) {reply = rpl;}
|
||||||
QNetworkReply* getReply() {return reply;}
|
QNetworkReply* getReply() {return reply;}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void ready();
|
void ready();
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setJson() {json = reply->readAll();}
|
void setJson() {json = reply->readAll();}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString json;
|
QString json;
|
||||||
QNetworkReply *reply = nullptr;
|
QNetworkReply *reply = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,90 +1,90 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "subject.h"
|
#include "subject.h"
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
Subject::Subject(const QString &name)
|
Subject::Subject(const QString &name)
|
||||||
{
|
{
|
||||||
setName(name);
|
setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Subject::getEmail() const {
|
QString Subject::getEmail() const {
|
||||||
return attributes["email"].toString();
|
return attributes["email"].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Subject::fromJSON(const QJsonObject &json) {
|
void Subject::fromJSON(const QJsonObject &json) {
|
||||||
Entity::fromJSON(json);
|
Entity::fromJSON(json);
|
||||||
|
|
||||||
attributes = json["attributes"].toObject()["items"].toObject();
|
attributes = json["attributes"].toObject()["items"].toObject();
|
||||||
for (const auto & attributeType : attributeTypes)
|
for (const auto & attributeType : attributeTypes)
|
||||||
{
|
{
|
||||||
if (!attributes[attributeType].toString().isEmpty()){
|
if (!attributes[attributeType].toString().isEmpty()){
|
||||||
atr.append(qMakePair(attributeType, attributes[attributeType].toString()));
|
atr.append(qMakePair(attributeType, attributes[attributeType].toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto &tokenFlagsArray = json["tokenFlags"].toArray();
|
const auto &tokenFlagsArray = json["tokenFlags"].toArray();
|
||||||
for(const auto &flag : tokenFlagsArray){
|
for(const auto &flag : tokenFlagsArray){
|
||||||
tokenFlags.insert(flag.toString());
|
tokenFlags.insert(flag.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
pin = json["pin"].toString();
|
pin = json["pin"].toString();
|
||||||
|
|
||||||
const auto &pinFlagsArray = json["pinFlags"].toArray();
|
const auto &pinFlagsArray = json["pinFlags"].toArray();
|
||||||
for(const auto &flag : pinFlagsArray){
|
for(const auto &flag : pinFlagsArray){
|
||||||
pinFlags.insert(flag.toString());
|
pinFlags.insert(flag.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject Subject::toJSON() const {
|
QJsonObject Subject::toJSON() const {
|
||||||
QJsonObject json = Entity::toJSON();
|
QJsonObject json = Entity::toJSON();
|
||||||
|
|
||||||
QJsonObject items({{"items", attributes}});
|
QJsonObject items({{"items", attributes}});
|
||||||
json["atributes"] = items;
|
json["atributes"] = items;
|
||||||
json["tokenFlags"] = QJsonArray::fromStringList(tokenFlags.toList());
|
json["tokenFlags"] = QJsonArray::fromStringList(tokenFlags.toList());
|
||||||
json["pin"] = pin;
|
json["pin"] = pin;
|
||||||
json["pinFlags"] = QJsonArray::fromStringList(pinFlags.toList());
|
json["pinFlags"] = QJsonArray::fromStringList(pinFlags.toList());
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QJsonObject &Subject::getAttributes() const {
|
const QJsonObject &Subject::getAttributes() const {
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Subject::setAttributes(const QJsonObject &attributes) {
|
void Subject::setAttributes(const QJsonObject &attributes) {
|
||||||
Subject::attributes = attributes;
|
Subject::attributes = attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSet<QString> &Subject::getTokenFlags() const {
|
const QSet<QString> &Subject::getTokenFlags() const {
|
||||||
return tokenFlags;
|
return tokenFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Subject::setTokenFlags(const QSet<QString> &tokenFlags) {
|
void Subject::setTokenFlags(const QSet<QString> &tokenFlags) {
|
||||||
Subject::tokenFlags = tokenFlags;
|
Subject::tokenFlags = tokenFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Subject::getPin() const {
|
const QString &Subject::getPin() const {
|
||||||
return pin;
|
return pin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Subject::setPin(const QString &pin) {
|
void Subject::setPin(const QString &pin) {
|
||||||
Subject::pin = pin;
|
Subject::pin = pin;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSet<QString> &Subject::getPinFlags() const {
|
const QSet<QString> &Subject::getPinFlags() const {
|
||||||
return pinFlags;
|
return pinFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Subject::setPinFlags(const QSet<QString> &pinFlags) {
|
void Subject::setPinFlags(const QSet<QString> &pinFlags) {
|
||||||
Subject::pinFlags = pinFlags;
|
Subject::pinFlags = pinFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<QPair<QString, QString>> &Subject::getAtr() const {
|
const QList<QPair<QString, QString>> &Subject::getAtr() const {
|
||||||
return atr;
|
return atr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Subject::setAtr(const QList<QPair<QString, QString>> &atr) {
|
void Subject::setAtr(const QList<QPair<QString, QString>> &atr) {
|
||||||
this->atr = atr;
|
this->atr = atr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,41 +1,41 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
|
||||||
class Subject : public Entity {
|
class Subject : public Entity {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Entity::Entity;
|
using Entity::Entity;
|
||||||
Subject() = default;
|
Subject() = default;
|
||||||
Subject(const QString& name);
|
Subject(const QString& name);
|
||||||
|
|
||||||
QString getEmail() const;
|
QString getEmail() const;
|
||||||
|
|
||||||
const QJsonObject &getAttributes() const;
|
const QJsonObject &getAttributes() const;
|
||||||
void setAttributes(const QJsonObject &attributes);
|
void setAttributes(const QJsonObject &attributes);
|
||||||
const QSet<QString> &getTokenFlags() const;
|
const QSet<QString> &getTokenFlags() const;
|
||||||
void setTokenFlags(const QSet<QString> &tokenFlags);
|
void setTokenFlags(const QSet<QString> &tokenFlags);
|
||||||
const QString &getPin() const;
|
const QString &getPin() const;
|
||||||
void setPin(const QString &pin);
|
void setPin(const QString &pin);
|
||||||
const QSet<QString> &getPinFlags() const;
|
const QSet<QString> &getPinFlags() const;
|
||||||
void setPinFlags(const QSet<QString> &pinFlags);
|
void setPinFlags(const QSet<QString> &pinFlags);
|
||||||
|
|
||||||
const QList<QPair<QString, QString>> &getAtr() const;
|
const QList<QPair<QString, QString>> &getAtr() const;
|
||||||
void setAtr(const QList<QPair<QString, QString>> &atr);
|
void setAtr(const QList<QPair<QString, QString>> &atr);
|
||||||
|
|
||||||
void fromJSON(const QJsonObject &json) override;
|
void fromJSON(const QJsonObject &json) override;
|
||||||
QJsonObject toJSON() const override;
|
QJsonObject toJSON() const override;
|
||||||
private:
|
private:
|
||||||
QJsonObject attributes;
|
QJsonObject attributes;
|
||||||
QSet<QString> tokenFlags;
|
QSet<QString> tokenFlags;
|
||||||
QString pin;
|
QString pin;
|
||||||
QSet<QString> pinFlags;
|
QSet<QString> pinFlags;
|
||||||
QList<QPair<QString, QString>> atr;
|
QList<QPair<QString, QString>> atr;
|
||||||
const QList<QString> attributeTypes = {"Jmeno", "Prijmeni", "ProfilParking", "Spolecnost", "Profil", "spz"};
|
const QList<QString> attributeTypes = {"Jmeno", "Prijmeni", "ProfilParking", "Spolecnost", "Profil", "spz"};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,59 +1,59 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "requestmanager.h"
|
#include "requestmanager.h"
|
||||||
#include "datamanager.h"
|
#include "datamanager.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
class SyncManager : public QObject
|
class SyncManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SyncManager(bool dryMode = false);
|
SyncManager(bool dryMode = false);
|
||||||
|
|
||||||
void syncDataFromColnodToDB();
|
void syncDataFromColnodToDB();
|
||||||
void syncDataFromDBToColnod();
|
void syncDataFromDBToColnod();
|
||||||
|
|
||||||
void prepareDatabase();
|
void prepareDatabase();
|
||||||
|
|
||||||
bool isValid();
|
bool isValid();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadDataFromColnod();
|
void loadDataFromColnod();
|
||||||
void loadDataFromDB();
|
void loadDataFromDB();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataDownloaded();
|
void dataDownloaded();
|
||||||
void dataUpdatedToColnod();
|
void dataUpdatedToColnod();
|
||||||
void syncFinished();
|
void syncFinished();
|
||||||
void error();
|
void error();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadTokensFromColnod();
|
void loadTokensFromColnod();
|
||||||
void loadUpdatedDataFromColnod();
|
void loadUpdatedDataFromColnod();
|
||||||
void loadDeletedDataFromColnod();
|
void loadDeletedDataFromColnod();
|
||||||
void loadUpdatedDataFromDB();
|
void loadUpdatedDataFromDB();
|
||||||
void loadDeletedDataFromDB();
|
void loadDeletedDataFromDB();
|
||||||
|
|
||||||
void syncUpdatedDataFromColnodToDB();
|
void syncUpdatedDataFromColnodToDB();
|
||||||
void syncDeletedDataFromColnodToDB();
|
void syncDeletedDataFromColnodToDB();
|
||||||
|
|
||||||
void syncUpdatedDataFromDBToColnod();
|
void syncUpdatedDataFromDBToColnod();
|
||||||
void syncDeletedDataFromDBToColnod();
|
void syncDeletedDataFromDBToColnod();
|
||||||
|
|
||||||
void areChangedDataReady();
|
void areChangedDataReady();
|
||||||
void areDataUpdatedToColnod();
|
void areDataUpdatedToColnod();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<RequestManager> reqMan;
|
std::unique_ptr<RequestManager> reqMan;
|
||||||
std::unique_ptr<DataManager> dataMan;
|
std::unique_ptr<DataManager> dataMan;
|
||||||
bool dryMode = false;
|
bool dryMode = false;
|
||||||
bool updateFinished = false;
|
bool updateFinished = false;
|
||||||
bool deleteFinished = false;
|
bool deleteFinished = false;
|
||||||
int dataCounter = 0;
|
int dataCounter = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,141 +1,141 @@
|
|||||||
#include "token.h"
|
#include "token.h"
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
Token::Token(const QString& name, QString tokenData, const QString& decription)
|
Token::Token(const QString& name, QString tokenData, const QString& decription)
|
||||||
{
|
{
|
||||||
this->setName(name);
|
this->setName(name);
|
||||||
this->tokenData = std::move(tokenData);
|
this->tokenData = std::move(tokenData);
|
||||||
this->setDescription(decription);
|
this->setDescription(decription);
|
||||||
this->setId(QUuid::createUuid());
|
this->setId(QUuid::createUuid());
|
||||||
this->tokenType = "Token";
|
this->tokenType = "Token";
|
||||||
this->tokenBits = 32;
|
this->tokenBits = 32;
|
||||||
this->timeToLive = 255;
|
this->timeToLive = 255;
|
||||||
this->authErrors = 255;
|
this->authErrors = 255;
|
||||||
this->flags = {"Enabled", "NoValidity"};
|
this->flags = {"Enabled", "NoValidity"};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Token(const QString &name)
|
Token::Token(const QString &name)
|
||||||
{
|
{
|
||||||
this->setName(name);
|
this->setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::~Token()
|
Token::~Token()
|
||||||
= default;
|
= default;
|
||||||
|
|
||||||
|
|
||||||
void Token::fromJSON(const QJsonObject &json) {
|
void Token::fromJSON(const QJsonObject &json) {
|
||||||
Entity::fromJSON(json);
|
Entity::fromJSON(json);
|
||||||
|
|
||||||
tokenType = json["tokenType"].toString();
|
tokenType = json["tokenType"].toString();
|
||||||
tokenBits = json["tokenBits"].toInt();
|
tokenBits = json["tokenBits"].toInt();
|
||||||
tokenData = json["tokenData"].toString();
|
tokenData = json["tokenData"].toString();
|
||||||
timeToLive = json["timeToLive"].toInt();
|
timeToLive = json["timeToLive"].toInt();
|
||||||
authErrors = json["authErrors"].toInt();
|
authErrors = json["authErrors"].toInt();
|
||||||
const auto &flagsArray = json["flags"].toArray();
|
const auto &flagsArray = json["flags"].toArray();
|
||||||
for(const auto &flag : flagsArray){
|
for(const auto &flag : flagsArray){
|
||||||
flags.insert(flag.toString());
|
flags.insert(flag.toString());
|
||||||
}
|
}
|
||||||
subjectId = json["subjectId"].toString();
|
subjectId = json["subjectId"].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject Token::toJSON() const {
|
QJsonObject Token::toJSON() const {
|
||||||
QJsonObject json = Entity::toJSON();
|
QJsonObject json = Entity::toJSON();
|
||||||
json.insert("tokenType", tokenType);
|
json.insert("tokenType", tokenType);
|
||||||
json["tokenBits"] = tokenBits;
|
json["tokenBits"] = tokenBits;
|
||||||
json["tokenType"] = tokenType;
|
json["tokenType"] = tokenType;
|
||||||
json["tokenBits"] = tokenBits;
|
json["tokenBits"] = tokenBits;
|
||||||
json["tokenData"] = tokenData;
|
json["tokenData"] = tokenData;
|
||||||
json["timeToLive"] = timeToLive;
|
json["timeToLive"] = timeToLive;
|
||||||
json["authErrors"] = authErrors;
|
json["authErrors"] = authErrors;
|
||||||
json["flags"] = QJsonArray::fromStringList(flags.toList());
|
json["flags"] = QJsonArray::fromStringList(flags.toList());
|
||||||
json["subjectId"] = subjectId.toString().mid(1,36);
|
json["subjectId"] = subjectId.toString().mid(1,36);
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::fromSQLRecord(const QSqlQuery& query)
|
void Token::fromSQLRecord(const QSqlQuery& query)
|
||||||
{
|
{
|
||||||
setId(query.value(0).toUuid());
|
setId(query.value(0).toUuid());
|
||||||
authErrors = query.value(1).toInt();
|
authErrors = query.value(1).toInt();
|
||||||
setDescription(query.value(2).toString());
|
setDescription(query.value(2).toString());
|
||||||
QSet<QString> flags;
|
QSet<QString> flags;
|
||||||
if (query.value(6).toBool())
|
if (query.value(6).toBool())
|
||||||
flags.insert("NoValidity");
|
flags.insert("NoValidity");
|
||||||
if (query.value(3).toBool())
|
if (query.value(3).toBool())
|
||||||
flags.insert("Enabled");
|
flags.insert("Enabled");
|
||||||
this->flags = flags;
|
this->flags = flags;
|
||||||
QDateTime date = query.value(4).toDateTime();
|
QDateTime date = query.value(4).toDateTime();
|
||||||
setLastUpdate(date.toMSecsSinceEpoch());
|
setLastUpdate(date.toMSecsSinceEpoch());
|
||||||
setName(query.value(5).toString());
|
setName(query.value(5).toString());
|
||||||
timeToLive = query.value(7).toInt();
|
timeToLive = query.value(7).toInt();
|
||||||
tokenBits = query.value(8).toInt();
|
tokenBits = query.value(8).toInt();
|
||||||
tokenData = query.value(9).toString();
|
tokenData = query.value(9).toString();
|
||||||
tokenType = query.value(10).toString();
|
tokenType = query.value(10).toString();
|
||||||
subjectId = query.value(11).toUuid();
|
subjectId = query.value(11).toUuid();
|
||||||
date = query.value(12).toDateTime();
|
date = query.value(12).toDateTime();
|
||||||
setLastModified(date.toMSecsSinceEpoch());
|
setLastModified(date.toMSecsSinceEpoch());
|
||||||
setDeleted(query.value(13).toBool());
|
setDeleted(query.value(13).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Token::getTokenType() const {
|
const QString &Token::getTokenType() const {
|
||||||
return tokenType;
|
return tokenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::setTokenType(const QString &tokenType) {
|
void Token::setTokenType(const QString &tokenType) {
|
||||||
Token::tokenType = tokenType;
|
Token::tokenType = tokenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Token::getTokenBits() const {
|
int Token::getTokenBits() const {
|
||||||
return tokenBits;
|
return tokenBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::setTokenBits(int tokenBits) {
|
void Token::setTokenBits(int tokenBits) {
|
||||||
Token::tokenBits = tokenBits;
|
Token::tokenBits = tokenBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Token::getTokenData() const {
|
const QString &Token::getTokenData() const {
|
||||||
return tokenData;
|
return tokenData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::setTokenData(const QString &tokenData) {
|
void Token::setTokenData(const QString &tokenData) {
|
||||||
Token::tokenData = tokenData;
|
Token::tokenData = tokenData;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Token::getTimeToLive() const {
|
int Token::getTimeToLive() const {
|
||||||
return timeToLive;
|
return timeToLive;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::setTimeToLive(int timeToLive) {
|
void Token::setTimeToLive(int timeToLive) {
|
||||||
Token::timeToLive = timeToLive;
|
Token::timeToLive = timeToLive;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Token::getAuthErrors() const {
|
int Token::getAuthErrors() const {
|
||||||
return authErrors;
|
return authErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::setAuthErrors(int authErrors) {
|
void Token::setAuthErrors(int authErrors) {
|
||||||
Token::authErrors = authErrors;
|
Token::authErrors = authErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSet<QString> &Token::getFlags() const {
|
const QSet<QString> &Token::getFlags() const {
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::setFlags(const QSet<QString> &flags) {
|
void Token::setFlags(const QSet<QString> &flags) {
|
||||||
Token::flags = flags;
|
Token::flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QUuid &Token::getSubjectId() const {
|
const QUuid &Token::getSubjectId() const {
|
||||||
return subjectId;
|
return subjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::setSubjectId(const QUuid &subjectId) {
|
void Token::setSubjectId(const QUuid &subjectId) {
|
||||||
Token::subjectId = subjectId;
|
Token::subjectId = subjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Token::subjectIdToStringWithoutBraces(){
|
QString Token::subjectIdToStringWithoutBraces(){
|
||||||
return subjectId.toString().mid(1,36);
|
return subjectId.toString().mid(1,36);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,70 +1,70 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <qsqlquery.h>
|
#include <qsqlquery.h>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
class Token : public Entity {
|
class Token : public Entity {
|
||||||
public:
|
public:
|
||||||
// using Entity::Entity;
|
// using Entity::Entity;
|
||||||
|
|
||||||
Token() = default;
|
Token() = default;
|
||||||
Token(const QString& name, QString tokenData, const QString& decription = "mobile");
|
Token(const QString& name, QString tokenData, const QString& decription = "mobile");
|
||||||
Token(const QString& name);
|
Token(const QString& name);
|
||||||
~Token() override;
|
~Token() override;
|
||||||
|
|
||||||
friend bool operator<(const Token &lToken, const Token &rToken){
|
friend bool operator<(const Token &lToken, const Token &rToken){
|
||||||
return lToken.getLastModified() < rToken.getLastUpdate();
|
return lToken.getLastModified() < rToken.getLastUpdate();
|
||||||
}
|
}
|
||||||
friend bool operator>(const Token &lToken, const Token &rToken){
|
friend bool operator>(const Token &lToken, const Token &rToken){
|
||||||
return lToken.getLastModified() > rToken.getLastUpdate();
|
return lToken.getLastModified() > rToken.getLastUpdate();
|
||||||
}
|
}
|
||||||
friend bool operator==(const Token &lToken, const Token &rToken){
|
friend bool operator==(const Token &lToken, const Token &rToken){
|
||||||
return lToken.getId() == rToken.getId() &&
|
return lToken.getId() == rToken.getId() &&
|
||||||
lToken.getName() == rToken.getName() &&
|
lToken.getName() == rToken.getName() &&
|
||||||
lToken.getDescription() == rToken.getDescription() &&
|
lToken.getDescription() == rToken.getDescription() &&
|
||||||
lToken.getLastUpdate() == rToken.getLastUpdate() &&
|
lToken.getLastUpdate() == rToken.getLastUpdate() &&
|
||||||
lToken.tokenType == rToken.tokenType &&
|
lToken.tokenType == rToken.tokenType &&
|
||||||
lToken.tokenBits == rToken.tokenBits &&
|
lToken.tokenBits == rToken.tokenBits &&
|
||||||
lToken.tokenData == rToken.tokenData &&
|
lToken.tokenData == rToken.tokenData &&
|
||||||
lToken.timeToLive == rToken.timeToLive &&
|
lToken.timeToLive == rToken.timeToLive &&
|
||||||
lToken.authErrors == rToken.authErrors &&
|
lToken.authErrors == rToken.authErrors &&
|
||||||
lToken.flags == rToken.flags &&
|
lToken.flags == rToken.flags &&
|
||||||
lToken.subjectId == rToken.subjectId;
|
lToken.subjectId == rToken.subjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString &getTokenType() const;
|
const QString &getTokenType() const;
|
||||||
void setTokenType(const QString &tokenType);
|
void setTokenType(const QString &tokenType);
|
||||||
int getTokenBits() const;
|
int getTokenBits() const;
|
||||||
void setTokenBits(int tokenBits);
|
void setTokenBits(int tokenBits);
|
||||||
const QString &getTokenData() const;
|
const QString &getTokenData() const;
|
||||||
void setTokenData(const QString &tokenData);
|
void setTokenData(const QString &tokenData);
|
||||||
int getTimeToLive() const;
|
int getTimeToLive() const;
|
||||||
void setTimeToLive(int timeToLive);
|
void setTimeToLive(int timeToLive);
|
||||||
int getAuthErrors() const;
|
int getAuthErrors() const;
|
||||||
void setAuthErrors(int authErrors);
|
void setAuthErrors(int authErrors);
|
||||||
const QSet<QString> &getFlags() const;
|
const QSet<QString> &getFlags() const;
|
||||||
void setFlags(const QSet<QString> &flags);
|
void setFlags(const QSet<QString> &flags);
|
||||||
const QUuid &getSubjectId() const;
|
const QUuid &getSubjectId() const;
|
||||||
void setSubjectId(const QUuid &subjectId);
|
void setSubjectId(const QUuid &subjectId);
|
||||||
|
|
||||||
|
|
||||||
QString subjectIdToStringWithoutBraces();
|
QString subjectIdToStringWithoutBraces();
|
||||||
|
|
||||||
void fromSQLRecord(const QSqlQuery& query);
|
void fromSQLRecord(const QSqlQuery& query);
|
||||||
void fromJSON(const QJsonObject &json) override;
|
void fromJSON(const QJsonObject &json) override;
|
||||||
QJsonObject toJSON() const override;
|
QJsonObject toJSON() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString tokenType;
|
QString tokenType;
|
||||||
int tokenBits{};
|
int tokenBits{};
|
||||||
QString tokenData;
|
QString tokenData;
|
||||||
int timeToLive{};
|
int timeToLive{};
|
||||||
int authErrors{};
|
int authErrors{};
|
||||||
QSet<QString> flags;
|
QSet<QString> flags;
|
||||||
QUuid subjectId;
|
QUuid subjectId;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,34 +1,34 @@
|
|||||||
{
|
{
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"id": "582c982d-6fd7-4856-8548-7ce542791c7a",
|
"id": "582c982d-6fd7-4856-8548-7ce542791c7a",
|
||||||
"name": "test",
|
"name": "test",
|
||||||
"description": "mobile",
|
"description": "mobile",
|
||||||
"tokenType": "Token",
|
"tokenType": "Token",
|
||||||
"tokenBits": 32,
|
"tokenBits": 32,
|
||||||
"tokenData": "7B9D32",
|
"tokenData": "7B9D32",
|
||||||
"timeToLive": 255,
|
"timeToLive": 255,
|
||||||
"authErrors": 255,
|
"authErrors": 255,
|
||||||
"flags": [
|
"flags": [
|
||||||
"Enabled",
|
"Enabled",
|
||||||
"NoValidity"
|
"NoValidity"
|
||||||
],
|
],
|
||||||
"subjectId": "72b37f7e-5761-4e6c-8e87-20c0bed0d904"
|
"subjectId": "72b37f7e-5761-4e6c-8e87-20c0bed0d904"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "3ff23b41-3da3-4b33-82ce-d8e2d8c9a546",
|
"id": "3ff23b41-3da3-4b33-82ce-d8e2d8c9a546",
|
||||||
"name": "test1",
|
"name": "test1",
|
||||||
"description": "mobile",
|
"description": "mobile",
|
||||||
"tokenType": "Token",
|
"tokenType": "Token",
|
||||||
"tokenBits": 32,
|
"tokenBits": 32,
|
||||||
"tokenData": "7B9D12",
|
"tokenData": "7B9D12",
|
||||||
"timeToLive": 255,
|
"timeToLive": 255,
|
||||||
"authErrors": 255,
|
"authErrors": 255,
|
||||||
"flags": [
|
"flags": [
|
||||||
"Enabled",
|
"Enabled",
|
||||||
"NoValidity"
|
"NoValidity"
|
||||||
],
|
],
|
||||||
"subjectId": "72b37f7e-5761-4e6c-8e87-20c0bed0d904"
|
"subjectId": "72b37f7e-5761-4e6c-8e87-20c0bed0d904"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1,303 +1,303 @@
|
|||||||
#include "unittest.h"
|
#include "unittest.h"
|
||||||
|
|
||||||
void UnitTest::initTestCase()
|
void UnitTest::initTestCase()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::loginSuccessfully()
|
void UnitTest::loginSuccessfully()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::successLogin);
|
QSignalSpy spy(&testAccess, &RequestManager::successLogin);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
testAccess.login();
|
testAccess.login();
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
|
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = testAccess.jsonResponse;
|
QString json = testAccess.jsonResponse;
|
||||||
qDebug() << json;
|
qDebug() << json;
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||||
QVERIFY2(doc.object().value("id").isString(), "No parameter 'id' in response");
|
QVERIFY2(doc.object().value("id").isString(), "No parameter 'id' in response");
|
||||||
}
|
}
|
||||||
|
|
||||||
//POST request w/o datas
|
//POST request w/o datas
|
||||||
void UnitTest::getSubjects()
|
void UnitTest::getSubjects()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
Response* response = testAccess.getSubjects();
|
Response* response = testAccess.getSubjects();
|
||||||
QSignalSpy spy1(response, &Response::ready);
|
QSignalSpy spy1(response, &Response::ready);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QCOMPARE(spy1.count(), 1);
|
QCOMPARE(spy1.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||||
QVERIFY(doc.isObject());
|
QVERIFY(doc.isObject());
|
||||||
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
||||||
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
||||||
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getTokens()
|
void UnitTest::getTokens()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
Response* response = testAccess.getTokens();
|
Response* response = testAccess.getTokens();
|
||||||
QSignalSpy spy(response, &Response::ready);
|
QSignalSpy spy(response, &Response::ready);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||||
QVERIFY(doc.isObject());
|
QVERIFY(doc.isObject());
|
||||||
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
||||||
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
||||||
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getTokenSubject()
|
void UnitTest::getTokenSubject()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getTokenSubject();
|
Response* response = testAccess.getTokenSubject();
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getSubjectsUpdated()
|
void UnitTest::getSubjectsUpdated()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getSubjectsUpdated(epochMS);
|
Response* response = testAccess.getSubjectsUpdated(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getSubjectsDeleted()
|
void UnitTest::getSubjectsDeleted()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getSubjectsDeleted(epochMS);
|
Response* response = testAccess.getSubjectsDeleted(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getTokensUpdated()
|
void UnitTest::getTokensUpdated()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getTokensUpdated(epochMS);
|
Response* response = testAccess.getTokensUpdated(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getTokensDeleted()
|
void UnitTest::getTokensDeleted()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getTokensDeleted(epochMS);
|
Response* response = testAccess.getTokensDeleted(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroups()
|
void UnitTest::getAccessGroups()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getAccessGroups();
|
Response* response = testAccess.getAccessGroups();
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroupsUpdated()
|
void UnitTest::getAccessGroupsUpdated()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getAccessGroupsUpdated(epochMS);
|
Response* response = testAccess.getAccessGroupsUpdated(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroupsDeleted()
|
void UnitTest::getAccessGroupsDeleted()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getAccessGroupsDeleted(epochMS);
|
Response* response = testAccess.getAccessGroupsDeleted(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroupMembership()
|
void UnitTest::getAccessGroupMembership()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getAccessGroupMembership();
|
Response* response = testAccess.getAccessGroupMembership();
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroupMembershipUpdated()
|
void UnitTest::getAccessGroupMembershipUpdated()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getAccessGroupMembershipUpdated(epochMS);
|
Response* response = testAccess.getAccessGroupMembershipUpdated(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getAccessGroupMembershipDeleted()
|
void UnitTest::getAccessGroupMembershipDeleted()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getAccessGroupMembershipDeleted(epochMS);
|
Response* response = testAccess.getAccessGroupMembershipDeleted(epochMS);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::setTokens()
|
void UnitTest::setTokens()
|
||||||
{
|
{
|
||||||
|
|
||||||
QHash<QString, std::shared_ptr<Token>> tokens;
|
QHash<QString, std::shared_ptr<Token>> tokens;
|
||||||
auto token = getTestToken();
|
auto token = getTestToken();
|
||||||
tokens.insert(token->idToStringWithoutBraces(), token);
|
tokens.insert(token->idToStringWithoutBraces(), token);
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.setTokens(tokens);
|
Response* response = testAccess.setTokens(tokens);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::deleteTokens()
|
void UnitTest::deleteTokens()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
QList<QString> ids;
|
QList<QString> ids;
|
||||||
ids.append("582c982d-6fd7-4856-8548-7ce542791c7a");
|
ids.append("582c982d-6fd7-4856-8548-7ce542791c7a");
|
||||||
ids.append("3ff23b41-3da3-4b33-82ce-d8e2d8c9a546");
|
ids.append("3ff23b41-3da3-4b33-82ce-d8e2d8c9a546");
|
||||||
Response* response = testAccess.deleteTokens(ids);
|
Response* response = testAccess.deleteTokens(ids);
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QVERIFY(!json.isEmpty());
|
QVERIFY(!json.isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::subjectJSONParser()
|
void UnitTest::subjectJSONParser()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getSubjects();
|
Response* response = testAccess.getSubjects();
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||||
QJsonArray arr = doc.object()["items"].toArray();
|
QJsonArray arr = doc.object()["items"].toArray();
|
||||||
Subject testSubject;
|
Subject testSubject;
|
||||||
testSubject.fromJSON(arr[1].toObject());
|
testSubject.fromJSON(arr[1].toObject());
|
||||||
qDebug() << testSubject.getName() << " Size: " << arr.size();
|
qDebug() << testSubject.getName() << " Size: " << arr.size();
|
||||||
QVERIFY(!testSubject.getName().isEmpty());
|
QVERIFY(!testSubject.getName().isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::tokenJSONParser()
|
void UnitTest::tokenJSONParser()
|
||||||
{
|
{
|
||||||
RequestManager testAccess;
|
RequestManager testAccess;
|
||||||
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
QSignalSpy spy(&testAccess, &RequestManager::responseReady);
|
||||||
Response* response = testAccess.getTokens();
|
Response* response = testAccess.getTokens();
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
QString json = response->getJson();
|
QString json = response->getJson();
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||||
QJsonArray arr = doc.object()["items"].toArray();
|
QJsonArray arr = doc.object()["items"].toArray();
|
||||||
Token testToken;
|
Token testToken;
|
||||||
testToken.fromJSON(arr[5].toObject());
|
testToken.fromJSON(arr[5].toObject());
|
||||||
qDebug() << testToken.getName() << " Size: " << arr.size();
|
qDebug() << testToken.getName() << " Size: " << arr.size();
|
||||||
QVERIFY(!testToken.getName().isEmpty());
|
QVERIFY(!testToken.getName().isEmpty());
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Token> UnitTest::getTestToken()
|
std::shared_ptr<Token> UnitTest::getTestToken()
|
||||||
{
|
{
|
||||||
QJsonObject jsonToken;
|
QJsonObject jsonToken;
|
||||||
jsonToken.insert("id", "062c93f6-ba3e-46af-a3a6-7a2988d1f0e9");
|
jsonToken.insert("id", "062c93f6-ba3e-46af-a3a6-7a2988d1f0e9");
|
||||||
jsonToken.insert("name", "test");
|
jsonToken.insert("name", "test");
|
||||||
jsonToken.insert("description", "mobile");
|
jsonToken.insert("description", "mobile");
|
||||||
jsonToken.insert("tokenType", "Token");
|
jsonToken.insert("tokenType", "Token");
|
||||||
jsonToken.insert("tokenBits", 32);
|
jsonToken.insert("tokenBits", 32);
|
||||||
jsonToken.insert("tokenData", "7B9D32");
|
jsonToken.insert("tokenData", "7B9D32");
|
||||||
jsonToken.insert("timeToLive", 255);
|
jsonToken.insert("timeToLive", 255);
|
||||||
jsonToken.insert("authErrors", 255);
|
jsonToken.insert("authErrors", 255);
|
||||||
QJsonArray flags;
|
QJsonArray flags;
|
||||||
flags.push_back("Enabled");
|
flags.push_back("Enabled");
|
||||||
flags.push_back("NoValidity");
|
flags.push_back("NoValidity");
|
||||||
jsonToken.insert("flags", flags);
|
jsonToken.insert("flags", flags);
|
||||||
jsonToken.insert("subjectId", "72b37f7e-5761-4e6c-8e87-20c0bed0d904");
|
jsonToken.insert("subjectId", "72b37f7e-5761-4e6c-8e87-20c0bed0d904");
|
||||||
auto token = std::make_shared<Token>();
|
auto token = std::make_shared<Token>();
|
||||||
token->fromJSON(jsonToken);
|
token->fromJSON(jsonToken);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(UnitTest)
|
QTEST_MAIN(UnitTest)
|
||||||
|
|||||||
@ -1,202 +1,202 @@
|
|||||||
#include "complextest.h"
|
#include "complextest.h"
|
||||||
|
|
||||||
void ComplexTest::initTestCase()
|
void ComplexTest::initTestCase()
|
||||||
{
|
{
|
||||||
// auto reqMan1 = new RequestManager;
|
// auto reqMan1 = new RequestManager;
|
||||||
// QList<QString> ids;
|
// QList<QString> ids;
|
||||||
// ids.append("582c982d-6fd7-4856-8548-7ce542791c7a");
|
// ids.append("582c982d-6fd7-4856-8548-7ce542791c7a");
|
||||||
// ids.append("3ff23b41-3da3-4b33-82ce-d8e2d8c9a546");
|
// ids.append("3ff23b41-3da3-4b33-82ce-d8e2d8c9a546");
|
||||||
// Response* deleteTokensResp = reqMan1->deleteTokens(ids);
|
// Response* deleteTokensResp = reqMan1->deleteTokens(ids);
|
||||||
// QSignalSpy deleteTokensRespSpy(deleteTokensResp, &Response::ready);
|
// QSignalSpy deleteTokensRespSpy(deleteTokensResp, &Response::ready);
|
||||||
// QCOMPARE(deleteTokensRespSpy.count(), 0);
|
// QCOMPARE(deleteTokensRespSpy.count(), 0);
|
||||||
// deleteTokensRespSpy.wait(timeout);
|
// deleteTokensRespSpy.wait(timeout);
|
||||||
// QTest::qWait(2500);
|
// QTest::qWait(2500);
|
||||||
// Logger *logger = Logger::getLogger();
|
// Logger *logger = Logger::getLogger();
|
||||||
start = QDateTime::currentMSecsSinceEpoch()-2000;
|
start = QDateTime::currentMSecsSinceEpoch()-2000;
|
||||||
api = new SyncManager();
|
api = new SyncManager();
|
||||||
qDebug() << start;
|
qDebug() << start;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ComplexTest::cleanupTestCase()
|
void ComplexTest::cleanupTestCase()
|
||||||
{
|
{
|
||||||
|
|
||||||
// QList<QString> ids;
|
// QList<QString> ids;
|
||||||
// ids.append("582c982d-6fd7-4856-8548-7ce542791c7a");
|
// ids.append("582c982d-6fd7-4856-8548-7ce542791c7a");
|
||||||
// ids.append("3ff23b41-3da3-4b33-82ce-d8e2d8c9a546");
|
// ids.append("3ff23b41-3da3-4b33-82ce-d8e2d8c9a546");
|
||||||
// auto reqMan = new RequestManager;
|
// auto reqMan = new RequestManager;
|
||||||
// Response* deleteTokensResp = reqMan->deleteTokens(ids);
|
// Response* deleteTokensResp = reqMan->deleteTokens(ids);
|
||||||
// QSignalSpy deleteTokensRespSpy(deleteTokensResp, &Response::ready);
|
// QSignalSpy deleteTokensRespSpy(deleteTokensResp, &Response::ready);
|
||||||
// QCOMPARE(deleteTokensRespSpy.count(), 0);
|
// QCOMPARE(deleteTokensRespSpy.count(), 0);
|
||||||
// deleteTokensRespSpy.wait(timeout);
|
// deleteTokensRespSpy.wait(timeout);
|
||||||
// QCOMPARE(deleteTokensRespSpy.count(), 1);
|
// QCOMPARE(deleteTokensRespSpy.count(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComplexTest::complexTest()
|
void ComplexTest::complexTest()
|
||||||
{
|
{
|
||||||
// // LOGIN_BEGIN
|
// // LOGIN_BEGIN
|
||||||
// reqMan = new RequestManager;
|
// reqMan = new RequestManager;
|
||||||
// QSignalSpy loginSpy(reqMan, &RequestManager::successLogin);
|
// QSignalSpy loginSpy(reqMan, &RequestManager::successLogin);
|
||||||
// auto loginResp = reqMan->login();
|
// auto loginResp = reqMan->login();
|
||||||
// QSignalSpy loginRespSpy(loginResp.get(), &Response::ready);
|
// QSignalSpy loginRespSpy(loginResp.get(), &Response::ready);
|
||||||
// QCOMPARE(loginSpy.count(), 0);
|
// QCOMPARE(loginSpy.count(), 0);
|
||||||
// QCOMPARE(loginRespSpy.count(), 0);
|
// QCOMPARE(loginRespSpy.count(), 0);
|
||||||
// loginSpy.wait(timeout);
|
// loginSpy.wait(timeout);
|
||||||
// QCOMPARE(loginResp->getStatusCode(), 200); // HTTP status code check
|
// QCOMPARE(loginResp->getStatusCode(), 200); // HTTP status code check
|
||||||
// QCOMPARE(loginSpy.count(), 1); // Checking multiple calls
|
// QCOMPARE(loginSpy.count(), 1); // Checking multiple calls
|
||||||
// QCOMPARE(loginRespSpy.count(), 1);
|
// QCOMPARE(loginRespSpy.count(), 1);
|
||||||
// auto doc0 = getJsonDoc(loginResp->getJson());
|
// auto doc0 = getJsonDoc(loginResp->getJson());
|
||||||
// QVERIFY(doc0.object()["id"].isString());
|
// QVERIFY(doc0.object()["id"].isString());
|
||||||
// // LOGIN_END
|
// // LOGIN_END
|
||||||
|
|
||||||
// // NUMBER_OF_SUBJECTS_AND_TOKENS_BEGIN
|
// // NUMBER_OF_SUBJECTS_AND_TOKENS_BEGIN
|
||||||
// int numOfSubjects = getNumOfSubjects();
|
// int numOfSubjects = getNumOfSubjects();
|
||||||
// QCOMPARE(numOfSubjects, 2893); // should be still the same, if false db has been changed
|
// QCOMPARE(numOfSubjects, 2893); // should be still the same, if false db has been changed
|
||||||
// int numOfTokens = getNumOfTokens();
|
// int numOfTokens = getNumOfTokens();
|
||||||
// QCOMPARE(numOfTokens, 2881); // should be still the same, if false db has been changed, or deleteTokens didnt work in previous test
|
// QCOMPARE(numOfTokens, 2881); // should be still the same, if false db has been changed, or deleteTokens didnt work in previous test
|
||||||
// // NUMBER_OF_SUBJECTS_AND_TOKENS_END
|
// // NUMBER_OF_SUBJECTS_AND_TOKENS_END
|
||||||
|
|
||||||
|
|
||||||
// // ADD_TOKENS_CHECK_BEGIN
|
// // ADD_TOKENS_CHECK_BEGIN
|
||||||
// QHash<QString, std::shared_ptr<Token>> tokens;
|
// QHash<QString, std::shared_ptr<Token>> tokens;
|
||||||
// auto token = getTestToken();
|
// auto token = getTestToken();
|
||||||
// tokens.insert(token->idToStringWithoutBraces(), token);
|
// tokens.insert(token->idToStringWithoutBraces(), token);
|
||||||
// Response* setTokensResp = reqMan->setTokens(tokens);
|
// Response* setTokensResp = reqMan->setTokens(tokens);
|
||||||
// QSignalSpy setTokensRespSpy(setTokensResp, &Response::ready);
|
// QSignalSpy setTokensRespSpy(setTokensResp, &Response::ready);
|
||||||
// QCOMPARE(setTokensRespSpy.count(), 0);
|
// QCOMPARE(setTokensRespSpy.count(), 0);
|
||||||
// setTokensRespSpy.wait(timeout);
|
// setTokensRespSpy.wait(timeout);
|
||||||
// QCOMPARE(setTokensRespSpy.count(), 1);
|
// QCOMPARE(setTokensRespSpy.count(), 1);
|
||||||
// QCOMPARE(setTokensResp->getStatusCode(), 200);
|
// QCOMPARE(setTokensResp->getStatusCode(), 200);
|
||||||
// QCOMPARE(getNumOfTokens(), numOfTokens + 1);
|
// QCOMPARE(getNumOfTokens(), numOfTokens + 1);
|
||||||
// // ADD_TOKENS_CHEK_END
|
// // ADD_TOKENS_CHEK_END
|
||||||
|
|
||||||
// // CHECK_UPDATED_TOKENS_BEGIN
|
// // CHECK_UPDATED_TOKENS_BEGIN
|
||||||
// Response* getTokensUpdatedResp = reqMan->getTokensUpdated(start);
|
// Response* getTokensUpdatedResp = reqMan->getTokensUpdated(start);
|
||||||
// //start = QDateTime::currentMSecsSinceEpoch();
|
// //start = QDateTime::currentMSecsSinceEpoch();
|
||||||
// QSignalSpy getTokensUpdatedRespSpy(getTokensUpdatedResp, &Response::ready);
|
// QSignalSpy getTokensUpdatedRespSpy(getTokensUpdatedResp, &Response::ready);
|
||||||
// QCOMPARE(getTokensUpdatedRespSpy.count(), 0);
|
// QCOMPARE(getTokensUpdatedRespSpy.count(), 0);
|
||||||
// getTokensUpdatedRespSpy.wait(timeout);
|
// getTokensUpdatedRespSpy.wait(timeout);
|
||||||
// QCOMPARE(getTokensUpdatedResp->getStatusCode(), 200);
|
// QCOMPARE(getTokensUpdatedResp->getStatusCode(), 200);
|
||||||
// QCOMPARE(getTokensUpdatedRespSpy.count(), 1);
|
// QCOMPARE(getTokensUpdatedRespSpy.count(), 1);
|
||||||
// auto doc1 = getJsonDoc(getTokensUpdatedResp->getJson());
|
// auto doc1 = getJsonDoc(getTokensUpdatedResp->getJson());
|
||||||
// QCOMPARE(doc1.object()["items"].toArray().size(), 1);
|
// QCOMPARE(doc1.object()["items"].toArray().size(), 1);
|
||||||
// // CHECK_UPDATED_TOKENS_END
|
// // CHECK_UPDATED_TOKENS_END
|
||||||
|
|
||||||
// // DELETE_TOKENS_CHECK_BEGIN
|
// // DELETE_TOKENS_CHECK_BEGIN
|
||||||
// QList<QString> ids;
|
// QList<QString> ids;
|
||||||
// ids.append("062c93f6-ba3e-46af-a3a6-7a2988d1f0e9");
|
// ids.append("062c93f6-ba3e-46af-a3a6-7a2988d1f0e9");
|
||||||
// Response* deleteTokensResp = reqMan->deleteTokens(ids);
|
// Response* deleteTokensResp = reqMan->deleteTokens(ids);
|
||||||
// QSignalSpy deleteTokensRespSpy(deleteTokensResp, &Response::ready);
|
// QSignalSpy deleteTokensRespSpy(deleteTokensResp, &Response::ready);
|
||||||
// QCOMPARE(deleteTokensRespSpy.count(), 0);
|
// QCOMPARE(deleteTokensRespSpy.count(), 0);
|
||||||
// deleteTokensRespSpy.wait(timeout);
|
// deleteTokensRespSpy.wait(timeout);
|
||||||
// QCOMPARE(deleteTokensRespSpy.count(), 1);
|
// QCOMPARE(deleteTokensRespSpy.count(), 1);
|
||||||
// QCOMPARE(deleteTokensResp->getStatusCode(), 200);
|
// QCOMPARE(deleteTokensResp->getStatusCode(), 200);
|
||||||
// // DELETE_TOKENS_CHECK_END
|
// // DELETE_TOKENS_CHECK_END
|
||||||
|
|
||||||
// // CHECK_DELETED_TOKENS_BEGIN
|
// // CHECK_DELETED_TOKENS_BEGIN
|
||||||
// Response* getTokensDeletedResp = reqMan->getTokensDeleted(start);
|
// Response* getTokensDeletedResp = reqMan->getTokensDeleted(start);
|
||||||
// start = QDateTime::currentMSecsSinceEpoch();
|
// start = QDateTime::currentMSecsSinceEpoch();
|
||||||
// QSignalSpy getTokensDeletedRespSpy(getTokensDeletedResp, &Response::ready);
|
// QSignalSpy getTokensDeletedRespSpy(getTokensDeletedResp, &Response::ready);
|
||||||
// QCOMPARE(getTokensDeletedRespSpy.count(), 0);
|
// QCOMPARE(getTokensDeletedRespSpy.count(), 0);
|
||||||
// getTokensDeletedRespSpy.wait(timeout);
|
// getTokensDeletedRespSpy.wait(timeout);
|
||||||
// QCOMPARE(getTokensDeletedResp->getStatusCode(), 200);
|
// QCOMPARE(getTokensDeletedResp->getStatusCode(), 200);
|
||||||
// QCOMPARE(getTokensDeletedRespSpy.count(), 1);
|
// QCOMPARE(getTokensDeletedRespSpy.count(), 1);
|
||||||
// auto doc2 = getJsonDoc(getTokensDeletedResp->getJson());
|
// auto doc2 = getJsonDoc(getTokensDeletedResp->getJson());
|
||||||
// QCOMPARE(doc2.object()["items"].toArray().size(), 1);
|
// QCOMPARE(doc2.object()["items"].toArray().size(), 1);
|
||||||
// QVERIFY(doc2.object()["items"].toArray().contains("062c93f6-ba3e-46af-a3a6-7a2988d1f0e9"));
|
// QVERIFY(doc2.object()["items"].toArray().contains("062c93f6-ba3e-46af-a3a6-7a2988d1f0e9"));
|
||||||
// // CHECK_DELETED_TOKENS_END
|
// // CHECK_DELETED_TOKENS_END
|
||||||
|
|
||||||
// // LAST_TESTS (for sure)
|
// // LAST_TESTS (for sure)
|
||||||
// QCOMPARE(loginSpy.count(), 1); // Checking multiple calls
|
// QCOMPARE(loginSpy.count(), 1); // Checking multiple calls
|
||||||
// QCOMPARE(loginRespSpy.count(), 1);
|
// QCOMPARE(loginRespSpy.count(), 1);
|
||||||
// QCOMPARE(getNumOfSubjects(), numOfSubjects);
|
// QCOMPARE(getNumOfSubjects(), numOfSubjects);
|
||||||
// QCOMPARE(getNumOfTokens(), numOfTokens);
|
// QCOMPARE(getNumOfTokens(), numOfTokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComplexTest::fullSync()
|
void ComplexTest::fullSync()
|
||||||
{
|
{
|
||||||
/* api->prepareDatabase();
|
/* api->prepareDatabase();
|
||||||
api->loadDataFromColnod();
|
api->loadDataFromColnod();
|
||||||
QSignalSpy spy(api, &SyncManager::dataDownloaded);
|
QSignalSpy spy(api, &SyncManager::dataDownloaded);
|
||||||
spy.wait(timeout);
|
spy.wait(timeout);
|
||||||
api->loadDataFromDB();
|
api->loadDataFromDB();
|
||||||
api->syncDataFromColnodToDB();
|
api->syncDataFromColnodToDB();
|
||||||
api->syncDataFromDBToColnod();
|
api->syncDataFromDBToColnod();
|
||||||
QSignalSpy processSpy(api, &SyncManager::dataUpdatedToColnod);
|
QSignalSpy processSpy(api, &SyncManager::dataUpdatedToColnod);
|
||||||
processSpy.wait(timeout);
|
processSpy.wait(timeout);
|
||||||
QSignalSpy finish(api, &SyncManager::syncFinished);
|
QSignalSpy finish(api, &SyncManager::syncFinished);
|
||||||
finish.wait(timeout); */
|
finish.wait(timeout); */
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComplexTest::syncLastUpdated()
|
void ComplexTest::syncLastUpdated()
|
||||||
{
|
{
|
||||||
// Logger::log("ahoj");
|
// Logger::log("ahoj");
|
||||||
// api->loadDataFromColnod();
|
// api->loadDataFromColnod();
|
||||||
// QSignalSpy spy(api, &SyncManager::dataDownloaded);
|
// QSignalSpy spy(api, &SyncManager::dataDownloaded);
|
||||||
// spy.wait(timeout);
|
// spy.wait(timeout);
|
||||||
// api->loadDataFromDB();
|
// api->loadDataFromDB();
|
||||||
// api->syncDataFromColnodToDB();
|
// api->syncDataFromColnodToDB();
|
||||||
// api->syncDataFromDBToColnod();
|
// api->syncDataFromDBToColnod();
|
||||||
// QSignalSpy processSpy(api, &SyncManager::dataUpdatedToColnod);
|
// QSignalSpy processSpy(api, &SyncManager::dataUpdatedToColnod);
|
||||||
// processSpy.wait(timeout);
|
// processSpy.wait(timeout);
|
||||||
// QSignalSpy finish(api, &SyncManager::syncFinished);
|
// QSignalSpy finish(api, &SyncManager::syncFinished);
|
||||||
// finish.wait(timeout);
|
// finish.wait(timeout);
|
||||||
// qDebug() << "All right, at least should be.";
|
// qDebug() << "All right, at least should be.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComplexTest::testingStuff()
|
void ComplexTest::testingStuff()
|
||||||
{
|
{
|
||||||
//DatabaseManager* db = new DatabaseManager("192.168.1.94", "deloitte", "postgres", "34rjkciea12");
|
//DatabaseManager* db = new DatabaseManager("192.168.1.94", "deloitte", "postgres", "34rjkciea12");
|
||||||
//DatabaseManager* db = new DatabaseManager("localhost", "deloitte", "postgres", "34rjkciea12");
|
//DatabaseManager* db = new DatabaseManager("localhost", "deloitte", "postgres", "34rjkciea12");
|
||||||
//db->makeTestingLast_sync();
|
//db->makeTestingLast_sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// HELPFUL_FUNCTIONS
|
// HELPFUL_FUNCTIONS
|
||||||
int ComplexTest::getNumOfSubjects()
|
int ComplexTest::getNumOfSubjects()
|
||||||
{
|
{
|
||||||
auto reqMan = new RequestManager;
|
auto reqMan = new RequestManager;
|
||||||
Response* subjectsResp = reqMan->getSubjects();
|
Response* subjectsResp = reqMan->getSubjects();
|
||||||
QSignalSpy subjectsRespSpy(subjectsResp, &Response::ready);
|
QSignalSpy subjectsRespSpy(subjectsResp, &Response::ready);
|
||||||
subjectsRespSpy.wait(timeout);
|
subjectsRespSpy.wait(timeout);
|
||||||
auto doc = getJsonDoc(subjectsResp->getJson());
|
auto doc = getJsonDoc(subjectsResp->getJson());
|
||||||
return doc.object()["items"].toArray().size();
|
return doc.object()["items"].toArray().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ComplexTest::getNumOfTokens()
|
int ComplexTest::getNumOfTokens()
|
||||||
{
|
{
|
||||||
auto reqMan = new RequestManager;
|
auto reqMan = new RequestManager;
|
||||||
Response* tokensResp = reqMan->getTokens();
|
Response* tokensResp = reqMan->getTokens();
|
||||||
QSignalSpy tokensRespSpy(tokensResp, &Response::ready);
|
QSignalSpy tokensRespSpy(tokensResp, &Response::ready);
|
||||||
tokensRespSpy.wait(timeout);
|
tokensRespSpy.wait(timeout);
|
||||||
auto doc = getJsonDoc(tokensResp->getJson());
|
auto doc = getJsonDoc(tokensResp->getJson());
|
||||||
return doc.object()["items"].toArray().size();
|
return doc.object()["items"].toArray().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonDocument ComplexTest::getJsonDoc(const QString &json)
|
QJsonDocument ComplexTest::getJsonDoc(const QString &json)
|
||||||
{
|
{
|
||||||
return QJsonDocument::fromJson(json.toUtf8());
|
return QJsonDocument::fromJson(json.toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Token> ComplexTest::getTestToken()
|
std::shared_ptr<Token> ComplexTest::getTestToken()
|
||||||
{
|
{
|
||||||
QJsonObject jsonToken;
|
QJsonObject jsonToken;
|
||||||
jsonToken.insert("id", "062c93f6-ba3e-46af-a3a6-7a2988d1f0e9");
|
jsonToken.insert("id", "062c93f6-ba3e-46af-a3a6-7a2988d1f0e9");
|
||||||
jsonToken.insert("name", "test");
|
jsonToken.insert("name", "test");
|
||||||
jsonToken.insert("description", "mobile");
|
jsonToken.insert("description", "mobile");
|
||||||
jsonToken.insert("tokenType", "Token");
|
jsonToken.insert("tokenType", "Token");
|
||||||
jsonToken.insert("tokenBits", 32);
|
jsonToken.insert("tokenBits", 32);
|
||||||
jsonToken.insert("tokenData", "7B9D32");
|
jsonToken.insert("tokenData", "7B9D32");
|
||||||
jsonToken.insert("timeToLive", 255);
|
jsonToken.insert("timeToLive", 255);
|
||||||
jsonToken.insert("authErrors", 255);
|
jsonToken.insert("authErrors", 255);
|
||||||
QJsonArray flags;
|
QJsonArray flags;
|
||||||
flags.push_back("Enabled");
|
flags.push_back("Enabled");
|
||||||
flags.push_back("NoValidity");
|
flags.push_back("NoValidity");
|
||||||
jsonToken.insert("flags", flags);
|
jsonToken.insert("flags", flags);
|
||||||
jsonToken.insert("subjectId", "72b37f7e-5761-4e6c-8e87-20c0bed0d904");
|
jsonToken.insert("subjectId", "72b37f7e-5761-4e6c-8e87-20c0bed0d904");
|
||||||
auto token = std::shared_ptr<Token>();
|
auto token = std::shared_ptr<Token>();
|
||||||
token->fromJSON(jsonToken);
|
token->fromJSON(jsonToken);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
//QTEST_MAIN(ComplexTest)
|
//QTEST_MAIN(ComplexTest)
|
||||||
|
|||||||
@ -1,40 +1,40 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include "response.h"
|
#include "response.h"
|
||||||
#include "requestmanager.h"
|
#include "requestmanager.h"
|
||||||
#include "syncmanager.h"
|
#include "syncmanager.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
class ComplexTest : public QObject
|
class ComplexTest : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void complexTest();
|
void complexTest();
|
||||||
void fullSync();
|
void fullSync();
|
||||||
void syncLastUpdated();
|
void syncLastUpdated();
|
||||||
void testingStuff();
|
void testingStuff();
|
||||||
void cleanupTestCase();
|
void cleanupTestCase();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
int getNumOfSubjects();
|
int getNumOfSubjects();
|
||||||
int getNumOfTokens();
|
int getNumOfTokens();
|
||||||
QJsonDocument getJsonDoc(const QString &json);
|
QJsonDocument getJsonDoc(const QString &json);
|
||||||
std::shared_ptr<Token> getTestToken();
|
std::shared_ptr<Token> getTestToken();
|
||||||
|
|
||||||
|
|
||||||
// VARIABLES
|
// VARIABLES
|
||||||
QString host = "https://192.168.1.3";
|
QString host = "https://192.168.1.3";
|
||||||
QString user = "spaceti";
|
QString user = "spaceti";
|
||||||
QString password = "spaceti1";
|
QString password = "spaceti1";
|
||||||
uint64_t start = 0;
|
uint64_t start = 0;
|
||||||
SyncManager* api = nullptr;
|
SyncManager* api = nullptr;
|
||||||
|
|
||||||
static constexpr qint16 timeout = 10000;
|
static constexpr qint16 timeout = 10000;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"host": "https://192.168.1.3:8443",
|
"host": "https://192.168.1.3:8443",
|
||||||
"username": "spaceti",
|
"username": "spaceti",
|
||||||
"password": "spaceti1"
|
"password": "spaceti1"
|
||||||
}
|
}
|
||||||
@ -1,17 +1,17 @@
|
|||||||
QT -= gui
|
QT -= gui
|
||||||
QT += core sql network testlib
|
QT += core sql network testlib
|
||||||
CONFIG += testcase # neccesary to have posibility to run: make check UnitTest
|
CONFIG += testcase # neccesary to have posibility to run: make check UnitTest
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
complextest.h \
|
complextest.h \
|
||||||
unittest.h
|
unittest.h
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
complextest.cpp \
|
complextest.cpp \
|
||||||
unittest.cpp
|
unittest.cpp
|
||||||
|
|
||||||
include(../../src/colnod/colnod.pri)
|
include(../../src/colnod/colnod.pri)
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
!isEmpty(target.path): INSTALLS += target
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|||||||
@ -1,51 +1,51 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
#include <requestmanager.h>
|
#include <requestmanager.h>
|
||||||
#include "subject.h"
|
#include "subject.h"
|
||||||
#include "databasemanager.h"
|
#include "databasemanager.h"
|
||||||
#include <QSslSocket>
|
#include <QSslSocket>
|
||||||
#include "datamanager.h"
|
#include "datamanager.h"
|
||||||
#include "response.h"
|
#include "response.h"
|
||||||
|
|
||||||
|
|
||||||
class UnitTest : public QObject
|
class UnitTest : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
|
||||||
void loginSuccessfully(); // /AaaManager/authSession
|
void loginSuccessfully(); // /AaaManager/authSession
|
||||||
void getSubjects(); // /SubjectManager/getSubjects
|
void getSubjects(); // /SubjectManager/getSubjects
|
||||||
void getTokens(); // /TokenManager/getTokens
|
void getTokens(); // /TokenManager/getTokens
|
||||||
void getTokenSubject(); // /OpenManager/getTokenSubject
|
void getTokenSubject(); // /OpenManager/getTokenSubject
|
||||||
void getSubjectsUpdated();
|
void getSubjectsUpdated();
|
||||||
void getSubjectsDeleted();
|
void getSubjectsDeleted();
|
||||||
void getTokensUpdated();
|
void getTokensUpdated();
|
||||||
void getTokensDeleted();
|
void getTokensDeleted();
|
||||||
void getAccessGroups();
|
void getAccessGroups();
|
||||||
void getAccessGroupsUpdated();
|
void getAccessGroupsUpdated();
|
||||||
void getAccessGroupsDeleted();
|
void getAccessGroupsDeleted();
|
||||||
void getAccessGroupMembership();
|
void getAccessGroupMembership();
|
||||||
void getAccessGroupMembershipUpdated();
|
void getAccessGroupMembershipUpdated();
|
||||||
void getAccessGroupMembershipDeleted();
|
void getAccessGroupMembershipDeleted();
|
||||||
void setTokens();
|
void setTokens();
|
||||||
void deleteTokens();
|
void deleteTokens();
|
||||||
void subjectJSONParser();
|
void subjectJSONParser();
|
||||||
void tokenJSONParser();
|
void tokenJSONParser();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Token> getTestToken();
|
std::shared_ptr<Token> getTestToken();
|
||||||
|
|
||||||
//QString host = "http://localhost:8080"; //colnod server (ssh -L 8080:192.168.254.11:8443 penta-master)
|
//QString host = "http://localhost:8080"; //colnod server (ssh -L 8080:192.168.254.11:8443 penta-master)
|
||||||
QString host = "https://192.168.1.3:8443"; //local testing server
|
QString host = "https://192.168.1.3:8443"; //local testing server
|
||||||
QString password = "spaceti1";
|
QString password = "spaceti1";
|
||||||
QString email = "spaceti";
|
QString email = "spaceti";
|
||||||
|
|
||||||
static constexpr int timeout = 10000;
|
static constexpr int timeout = 10000;
|
||||||
static constexpr qint64 epochMS = 1568646217767;
|
static constexpr qint64 epochMS = 1568646217767;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user