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