Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FIT-Connect-SDK - .NET
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIT-Connect
FIT-Connect-SDK - .NET
Commits
0164b630
Commit
0164b630
authored
1 year ago
by
Klaus Fischer
Browse files
Options
Downloads
Patches
Plain Diff
feature: add max file size finder
parent
48f85dec
No related branches found
No related tags found
1 merge request
!112
Draft: Feature/1731 big files encryption
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/EncryptionTests/FileEncryptionTest.cs
+22
-15
22 additions, 15 deletions
Tests/EncryptionTests/FileEncryptionTest.cs
with
22 additions
and
15 deletions
Tests/EncryptionTests/FileEncryptionTest.cs
+
22
−
15
View file @
0164b630
...
...
@@ -31,28 +31,16 @@ public class FileEncryptionTest {
_encryptedFile
=
_encryption
.
Encrypt
(
_sourceFile
);
}
[
Ignore
(
"Test takes too long"
)]
[
TestCase
(
1
)]
[
Ignore
(
"Takes much to long"
)]
[
TestCase
(
500
)]
[
TestCase
(
600
)]
[
TestCase
(
700
)]
[
TestCase
(
750
)]
[
TestCase
(
800
)]
[
TestCase
(
1000
)]
[
TestCase
(
2000
)]
[
TestCase
(
2047
)]
public
void
EncryptLargeFiles_ShouldPass
(
int
fileSizeInMb
)
{
Console
.
WriteLine
(
$"Encrypting
{
int
.
MaxValue
/
(
1024
*
1024
)}
MB file"
);
var
randomdMb
=
""
;
for
(
int
i
=
0
;
i
<
(
1024
*
1024
-
1
)
;
i
++)
{
randomdMb
+=
"a"
;
}
var
maxString
=
""
;
for
(
int
i
=
0
;
i
<
int
.
MaxValue
/
(
1024
*
1024
);
i
++)
{
maxString
+=
randomdMb
;
}
Console
.
WriteLine
(
$"Max String is
{
maxString
.
Length
/
(
1024
*
1024
)}
MB long"
);
// Arrange
var
sourceFile
=
RandomNumberGenerator
.
GetBytes
(
1024
*
1024
*
fileSizeInMb
);
Console
.
WriteLine
(
$"Encrypting
{
fileSizeInMb
}
MB file"
);
...
...
@@ -65,7 +53,24 @@ public class FileEncryptionTest {
// Assert
encryptedFile
.
Should
().
NotBeNullOrEmpty
();
}
[
Ignore
(
"Takes much to long"
)]
[
Test
]
public
void
FindMaxFileSizeForEncryption
()
{
for
(
var
start
=
750
;
start
<
800
;
start
++)
{
Console
.
Write
(
$"Trying to encrypt
{
start
}
MB file"
);
try
{
EncryptLargeFiles_ShouldPass
(
start
);
Console
.
WriteLine
(
"...success"
);
}
catch
(
Exception
e
)
{
Console
.
WriteLine
(
"...failed"
);
Console
.
WriteLine
(
e
);
Console
.
WriteLine
(
$"Max file size for encryption is
{
start
-
1
}
MB"
);
break
;
}
}
}
[
Test
]
...
...
@@ -102,7 +107,9 @@ public class FileEncryptionTest {
}"
;
Assert
.
Throws
<
EncryptionException
>(()
=>
{
var
result
=
new
FitEncryption
(
new
List
<
string
>
{
""
},
""
,
null
)
var
result
=
new
FitEncryption
(
new
List
<
string
>
{
""
},
""
,
null
)
.
Encrypt
(
"Test"
,
jsonWebKeyString
);
Console
.
WriteLine
(
result
);
});
...
...
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