Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
6b2925b2
Commit
6b2925b2
authored
3 years ago
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Remove unnecessary load, add bad json test
parent
f1f6ce87
No related branches found
No related tags found
3 merge requests
!231
Revert "Update store to print changes to the partners list"
,
!187
Xx 3829/triggers
,
!181
Xx 3818/jsonbackup
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
backup/backup.go
+1
-2
1 addition, 2 deletions
backup/backup.go
backup/backup_test.go
+38
-0
38 additions, 0 deletions
backup/backup_test.go
with
39 additions
and
2 deletions
backup/backup.go
+
1
−
2
View file @
6b2925b2
...
@@ -215,8 +215,7 @@ func (b *Backup) AddJson(newJson string) {
...
@@ -215,8 +215,7 @@ func (b *Backup) AddJson(newJson string) {
b
.
mux
.
Lock
()
b
.
mux
.
Lock
()
defer
b
.
mux
.
Unlock
()
defer
b
.
mux
.
Unlock
()
currentJson
:=
loadJson
(
b
.
store
.
GetKV
())
if
newJson
!=
b
.
jsonParams
{
if
newJson
!=
currentJson
{
b
.
jsonParams
=
newJson
b
.
jsonParams
=
newJson
if
err
:=
storeJson
(
newJson
,
b
.
store
.
GetKV
());
err
!=
nil
{
if
err
:=
storeJson
(
newJson
,
b
.
store
.
GetKV
());
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to store json: %+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"Failed to store json: %+v"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
backup/backup_test.go
+
38
−
0
View file @
6b2925b2
...
@@ -320,6 +320,44 @@ func TestBackup_AddJson(t *testing.T) {
...
@@ -320,6 +320,44 @@ func TestBackup_AddJson(t *testing.T) {
}
}
}
}
func
TestBackup_AddJson_badJson
(
t
*
testing
.
T
)
{
b
:=
newTestBackup
(
"MySuperSecurePassword"
,
nil
,
t
)
s
:=
b
.
store
json
:=
"abc{'i'm a bad json: 'one': 1'''}}"
expectedCollatedBackup
:=
backup
.
Backup
{
RegistrationTimestamp
:
s
.
GetUser
()
.
RegistrationTimestamp
,
TransmissionIdentity
:
backup
.
TransmissionIdentity
{
RSASigningPrivateKey
:
s
.
GetUser
()
.
TransmissionRSA
,
RegistrarSignature
:
s
.
User
()
.
GetTransmissionRegistrationValidationSignature
(),
Salt
:
s
.
GetUser
()
.
TransmissionSalt
,
ComputedID
:
s
.
GetUser
()
.
TransmissionID
,
},
ReceptionIdentity
:
backup
.
ReceptionIdentity
{
RSASigningPrivateKey
:
s
.
GetUser
()
.
ReceptionRSA
,
RegistrarSignature
:
s
.
User
()
.
GetReceptionRegistrationValidationSignature
(),
Salt
:
s
.
GetUser
()
.
ReceptionSalt
,
ComputedID
:
s
.
GetUser
()
.
ReceptionID
,
DHPrivateKey
:
s
.
GetUser
()
.
E2eDhPrivateKey
,
DHPublicKey
:
s
.
GetUser
()
.
E2eDhPublicKey
,
},
UserDiscoveryRegistration
:
backup
.
UserDiscoveryRegistration
{
FactList
:
s
.
GetUd
()
.
GetFacts
(),
},
Contacts
:
backup
.
Contacts
{
Identities
:
s
.
E2e
()
.
GetPartners
()},
JSONParams
:
json
,
}
b
.
AddJson
(
json
)
collatedBackup
:=
b
.
assembleBackup
()
if
!
reflect
.
DeepEqual
(
expectedCollatedBackup
,
collatedBackup
)
{
t
.
Errorf
(
"Collated backup does not match expected."
+
"
\n
expected: %+v
\n
received: %+v"
,
expectedCollatedBackup
,
collatedBackup
)
}
}
// Tests that Backup.assembleBackup returns the backup.Backup with the expected
// Tests that Backup.assembleBackup returns the backup.Backup with the expected
// results.
// results.
func
TestBackup_assembleBackup
(
t
*
testing
.
T
)
{
func
TestBackup_assembleBackup
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment