Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DCSG2900-ThreatTotal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johannes Barstad
DCSG2900-ThreatTotal
Commits
5b42dbda
Commit
5b42dbda
authored
3 years ago
by
Odin K. Henriksen
Browse files
Options
Downloads
Patches
Plain Diff
Added test to see if an unspecified endpoint returns 404
parent
5e7272ad
No related branches found
No related tags found
1 merge request
!2
Merge react-branch into main.
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main_test.go
+28
-0
28 additions, 0 deletions
main_test.go
with
28 additions
and
0 deletions
main_test.go
+
28
−
0
View file @
5b42dbda
...
@@ -294,3 +294,31 @@ func TestHash_IntelligenceValidOutput(t *testing.T) {
...
@@ -294,3 +294,31 @@ func TestHash_IntelligenceValidOutput(t *testing.T) {
t
.
Fatalf
(
"The status of AlienVault has is not as expected Risk, Status is: %s"
,
jsonResponse
.
FrontendResponse
[
1
]
.
EN
.
Status
)
t
.
Fatalf
(
"The status of AlienVault has is not as expected Risk, Status is: %s"
,
jsonResponse
.
FrontendResponse
[
1
]
.
EN
.
Status
)
}
}
}
}
/**
* This API test checks if an unspecified endpoint in the API returns 404 as expected
*
*/
func
TestNotSpecifiedEndpoint
(
t
*
testing
.
T
){
url
:=
"http://localhost:8081/ThisShouldNotExist"
req
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Error in request"
)
}
req
.
Header
.
Set
(
"Content-Type"
,
"application/json; charset=UTF-8"
)
client
:=
&
http
.
Client
{}
res
,
err
:=
client
.
Do
(
req
)
if
err
!=
nil
{
t
.
Fatalf
(
"Request to Hash-Intelligence failed"
)
}
defer
res
.
Body
.
Close
()
if
res
.
StatusCode
!=
http
.
StatusNotFound
{
t
.
Fatalf
(
"Staus code did not return 404 as expected, code returned %d"
,
res
.
StatusCode
)
}
}
\ No newline at end of file
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