Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
UFTest
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
datdiep
UFTest
Commits
8e7fb01d
Commit
8e7fb01d
authored
Jun 15, 2022
by
datdiep
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
64b8275b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
131 additions
and
10 deletions
+131
-10
ControllerTest.cs
TestProject1/ControllerTest.cs
+129
-8
HomeProvider.cs
UF.AssessmentProject/Providers/HomeProvider.cs
+2
-2
No files found.
TestProject1/ControllerTest.cs
View file @
8e7fb01d
...
...
@@ -20,11 +20,11 @@ namespace TestProject1
var
rq
=
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
RequestMessage
()
{
partnerkey
=
"FAKEGOOGLE"
,
partner
password
=
"FG-00001"
,
partner
refno
=
"RkFLRVBBU1NXT1JEMTIzNA=="
,
partner
refno
=
"FG-00001"
,
partner
password
=
"RkFLRVBBU1NXT1JEMTIzNA=="
,
sig
=
"24XYSmvKGH9I9Y5FLvSsId2MPtjkvog7U5JLhE3m30A="
,
timestamp
=
"2013-11-22T02:11:22.0000000Z"
,
totalamount
=
1
00
0
,
totalamount
=
1
1
0
,
items
=
new
List
<
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
>()
{
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
()
...
...
@@ -46,9 +46,90 @@ namespace TestProject1
ActionResult
<
UF
.
AssessmentProject
.
Model
.
Transaction
.
ResponseMessage
>
rs
=
_controller
.
SubmitTRansaction
(
rq
);
var
actual
=
(
OkObjectResult
)
rs
.
Result
;
var
resultmessage
=
actual
.
Value
as
UF
.
AssessmentProject
.
Model
.
Transaction
.
ResponseMessage
;
Assert
.
Equal
(
"Expired!"
,
resultmessage
.
resultmessage
);
Assert
.
True
(
resultmessage
.
resultmessage
==
"Expired!"
);
}
[
Fact
]
public
void
Partnerkey_isRequired
()
{
var
rq
=
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
RequestMessage
()
{
partnerrefno
=
"FG-00001"
,
partnerpassword
=
"RkFLRVBBU1NXT1JEMTIzNA=="
,
totalamount
=
110
,
items
=
new
List
<
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
>()
{
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
()
{
name
=
"i-00001"
,
partneritemref
=
"Pen"
,
qty
=
5
,
unitprice
=
2
},
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
()
{
name
=
"i-00002"
,
partneritemref
=
"Ruler"
,
qty
=
1
,
unitprice
=
100
}
}
};
rq
.
timestamp
=
DateTime
.
Now
.
ToString
();
var
rawsign
=
DateTime
.
Parse
(
rq
.
timestamp
).
ToString
(
"yyyyMMddHHmmss"
)
+
rq
.
partnerkey
+
rq
.
partnerrefno
+
rq
.
totalamount
+
rq
.
partnerpassword
;
string
sig
=
CommonUtils
.
ComputeSha256Hash
((
CommonUtils
.
EncodeBase64
(
rawsign
)));
rq
.
sig
=
sig
;
ActionResult
<
UF
.
AssessmentProject
.
Model
.
Transaction
.
ResponseMessage
>
rs
=
_controller
.
SubmitTRansaction
(
rq
);
var
actual
=
(
OkObjectResult
)
rs
.
Result
;
var
resultmessage
=
actual
.
Value
as
UF
.
AssessmentProject
.
Model
.
Transaction
.
ResponseMessage
;
Assert
.
True
(
resultmessage
.
resultmessage
==
"partnerkey is required!"
);
}
[
Fact
]
public
void
Invalid_total
()
{
var
rq
=
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
RequestMessage
()
{
partnerkey
=
"FAKEGOOGLE"
,
partnerrefno
=
"FG-00001"
,
partnerpassword
=
"RkFLRVBBU1NXT1JEMTIzNA=="
,
totalamount
=
9999
,
items
=
new
List
<
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
>()
{
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
()
{
name
=
"i-00001"
,
partneritemref
=
"Pen"
,
qty
=
5
,
unitprice
=
2
},
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
()
{
name
=
"i-00002"
,
partneritemref
=
"Ruler"
,
qty
=
1
,
unitprice
=
100
}
}
};
rq
.
timestamp
=
DateTime
.
Now
.
ToString
();
var
rawsign
=
DateTime
.
Parse
(
rq
.
timestamp
).
ToString
(
"yyyyMMddHHmmss"
)
+
rq
.
partnerkey
+
rq
.
partnerrefno
+
rq
.
totalamount
+
rq
.
partnerpassword
;
string
sig
=
CommonUtils
.
ComputeSha256Hash
((
CommonUtils
.
EncodeBase64
(
rawsign
)));
rq
.
sig
=
sig
;
ActionResult
<
UF
.
AssessmentProject
.
Model
.
Transaction
.
ResponseMessage
>
rs
=
_controller
.
SubmitTRansaction
(
rq
);
var
actual
=
(
OkObjectResult
)
rs
.
Result
;
var
resultmessage
=
actual
.
Value
as
UF
.
AssessmentProject
.
Model
.
Transaction
.
ResponseMessage
;
Assert
.
True
(
resultmessage
.
resultmessage
==
"Invalid Total Amount."
);
}
[
Fact
]
public
void
Access_denied
()
{
...
...
@@ -56,9 +137,9 @@ namespace TestProject1
var
rq
=
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
RequestMessage
()
{
partnerkey
=
"aaa"
,
partner
password
=
"FG-00001"
,
partner
refno
=
"RkFLRVBBU1NXT1JEMTIzNA=="
,
totalamount
=
1
00
0
,
partner
refno
=
"FG-00001"
,
partner
password
=
"RkFLRVBBU1NXT1JEMTIzNA=="
,
totalamount
=
1
1
0
,
items
=
new
List
<
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
>()
{
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
()
...
...
@@ -85,7 +166,47 @@ namespace TestProject1
ActionResult
<
UF
.
AssessmentProject
.
Model
.
Transaction
.
ResponseMessage
>
rs
=
_controller
.
SubmitTRansaction
(
rq
);
var
actual
=
(
OkObjectResult
)
rs
.
Result
;
var
resultmessage
=
actual
.
Value
as
UF
.
AssessmentProject
.
Model
.
Transaction
.
ResponseMessage
;
Assert
.
Equal
(
"Access Denied!"
,
resultmessage
.
resultmessage
);
Assert
.
True
(
resultmessage
.
resultmessage
==
"Access Denied!"
);
}
[
Fact
]
public
void
Unitprice_positive
()
{
var
rq
=
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
RequestMessage
()
{
partnerkey
=
"FAKEGOOGLE"
,
partnerrefno
=
"FG-00001"
,
partnerpassword
=
"RkFLRVBBU1NXT1JEMTIzNA=="
,
totalamount
=
110
,
items
=
new
List
<
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
>()
{
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
()
{
name
=
"i-00001"
,
partneritemref
=
"Pen"
,
qty
=
5
,
unitprice
=
-
10
},
new
UF
.
AssessmentProject
.
Model
.
Transaction
.
itemdetail
()
{
name
=
"i-00002"
,
partneritemref
=
"Ruler"
,
qty
=
1
,
unitprice
=
-
100
}
}
};
rq
.
timestamp
=
DateTime
.
Now
.
ToString
();
var
rawsign
=
DateTime
.
Parse
(
rq
.
timestamp
).
ToString
(
"yyyyMMddHHmmss"
)
+
rq
.
partnerkey
+
rq
.
partnerrefno
+
rq
.
totalamount
+
rq
.
partnerpassword
;
string
sig
=
CommonUtils
.
ComputeSha256Hash
((
CommonUtils
.
EncodeBase64
(
rawsign
)));
rq
.
sig
=
sig
;
ActionResult
<
UF
.
AssessmentProject
.
Model
.
Transaction
.
ResponseMessage
>
rs
=
_controller
.
SubmitTRansaction
(
rq
);
var
actual
=
(
OkObjectResult
)
rs
.
Result
;
var
resultmessage
=
actual
.
Value
as
UF
.
AssessmentProject
.
Model
.
Transaction
.
ResponseMessage
;
Assert
.
True
(
resultmessage
.
resultmessage
==
"unitprice only allow positive value!"
);
}
}
}
UF.AssessmentProject/Providers/HomeProvider.cs
View file @
8e7fb01d
...
...
@@ -64,7 +64,7 @@ namespace UF.AssessmentProject.Providers
string
sig
=
CommonUtils
.
ComputeSha256Hash
((
CommonUtils
.
EncodeBase64
(
rawsig
)));
var
partner
=
db
.
Partners
.
Where
(
c
=>
c
.
partnerkey
==
req
.
partnerkey
).
FirstOrDefault
();
if
(
partner
==
null
||
(
partner
!=
null
&&
CommonUtils
.
EncodeBase64
(
partner
.
partnerpassword
)
!=
req
.
partnerpassword
)
||
sig
!=
req
.
sig
)
if
(
partner
==
null
||
(
partner
!=
null
&&
(
CommonUtils
.
EncodeBase64
(
partner
.
partnerpassword
)
!=
req
.
partnerpassword
)
)
||
sig
!=
req
.
sig
)
{
return
new
Model
.
Transaction
.
ResponseMessage
{
...
...
@@ -94,7 +94,7 @@ namespace UF.AssessmentProject.Providers
}
var
checkUnitPrice
=
req
.
items
.
Where
(
x
=>
x
.
unitprice
<
0
).
ToList
().
Count
();
if
(
check
NameNull
>
0
)
if
(
check
UnitPrice
>
0
)
{
return
new
Model
.
Transaction
.
ResponseMessage
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment