Same as previous one, but different InternalRulesOrganizations
This one won't match with the authentication token used
|
serverConfigInternalOrganizations2 = server . Configuration {
Address : ":8081" ,
APIv1Prefix : "/api/v1/" ,
APIv2Prefix : "/api/v2/" ,
APIv1SpecFile : "server/api/v1/openapi.json" ,
APIv2SpecFile : "server/api/v2/openapi.json" ,
Debug : true ,
Auth : true ,
AuthType : "xrh" ,
UseHTTPS : false ,
EnableCORS : false ,
EnableInternalRulesOrganizations : true ,
InternalRulesOrganizations : [ ] ctypes . OrgID { 2 } ,
}
SmartProxyReportResponse1RuleNoContent = struct {
Status string `json:"status"`
Report * types . SmartProxyReport `json:"report"`
} {
Status : "ok" ,
Report : & SmartProxyReport1RuleNoContentNoAMSClient ,
}
SmartProxyReportResponse3Rules2NoContent = struct {
Status string `json:"status"`
Report * types . SmartProxyReport `json:"report"`
} {
Status : "ok" ,
Report : & SmartProxyReport3Rules2NoContentNoAMSClient ,
}
SmartProxyReportResponse3Rules = struct {
Status string `json:"status"`
Report * types . SmartProxyReport `json:"report"`
} {
Status : "ok" ,
Report : & SmartProxyReport3RulesNoAMSClient ,
}
SmartProxyReport1RuleNoContentNoAMSClient = types . SmartProxyReport {
Meta : types . ReportResponseMeta {
DisplayName : string ( testdata . ClusterName ) ,
Count : 0 ,
LastCheckedAt : types . Timestamp ( testdata . LastCheckedAt . UTC ( ) . Format ( time . RFC3339 ) ) ,
} ,
Data : [ ] types . RuleWithContentResponse { } ,
}
Report3RulesData = [ ] types . RuleWithContentResponse {
{
RuleID : testdata . Rule1 . Module ,
ErrorKey : testdata . RuleErrorKey1 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey1 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ,
Disabled : testdata . Rule1Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule1ExtraData ,
Tags : testdata . RuleErrorKey1 . Tags ,
} ,
{
RuleID : testdata . Rule2 . Module ,
ErrorKey : testdata . RuleErrorKey2 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey2 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey2 . Description ,
Generic : testdata . RuleErrorKey2 . Generic ,
Reason : testdata . RuleErrorKey2 . Reason ,
Resolution : testdata . RuleErrorKey2 . Resolution ,
MoreInfo : testdata . RuleErrorKey2 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey2 . Impact , testdata . RuleErrorKey2 . Likelihood ) ,
Disabled : testdata . Rule2Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule2ExtraData ,
Tags : testdata . RuleErrorKey2 . Tags ,
} ,
{
RuleID : testdata . Rule3 . Module ,
ErrorKey : testdata . RuleErrorKey3 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey3 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey3 . Description ,
Generic : testdata . RuleErrorKey3 . Generic ,
Reason : testdata . RuleErrorKey3 . Reason ,
Resolution : testdata . RuleErrorKey3 . Resolution ,
MoreInfo : testdata . RuleErrorKey3 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey3 . Impact , testdata . RuleErrorKey3 . Likelihood ) ,
Disabled : testdata . Rule3Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule3ExtraData ,
Tags : testdata . RuleErrorKey3 . Tags ,
} ,
}
SmartProxyReport3RulesNoAMSClient = types . SmartProxyReport {
Meta : types . ReportResponseMeta {
DisplayName : string ( testdata . ClusterName ) ,
Count : 3 ,
LastCheckedAt : types . Timestamp ( testdata . LastCheckedAt . UTC ( ) . Format ( time . RFC3339 ) ) ,
} ,
Data : Report3RulesData ,
}
Report3Rules2NoContentData = [ ] types . RuleWithContentResponse {
{
RuleID : testdata . Rule1 . Module ,
ErrorKey : testdata . RuleErrorKey1 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey1 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ,
Disabled : testdata . Rule1Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule1ExtraData ,
Tags : testdata . RuleErrorKey1 . Tags ,
} ,
}
SmartProxyReport3Rules2NoContentNoAMSClient = types . SmartProxyReport {
Meta : types . ReportResponseMeta {
DisplayName : string ( testdata . ClusterName ) ,
Count : 3 ,
LastCheckedAt : types . Timestamp ( testdata . LastCheckedAt . UTC ( ) . Format ( time . RFC3339 ) ) ,
} ,
Data : Report3Rules2NoContentData ,
}
Report3RulesWithOnlyOSDData = [ ] types . RuleWithContentResponse {
{
RuleID : testdata . Rule1 . Module ,
ErrorKey : testdata . RuleErrorKey1 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey1 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ,
Disabled : testdata . Rule1Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule1ExtraData ,
Tags : testdata . RuleErrorKey1 . Tags ,
} ,
}
Report3RulesOnlyEnabledData = [ ] types . RuleWithContentResponse {
{
RuleID : testdata . Rule1 . Module ,
ErrorKey : testdata . RuleErrorKey1 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey1 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ,
Disabled : testdata . Rule1Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule1ExtraData ,
Tags : testdata . RuleErrorKey1 . Tags ,
} ,
{
RuleID : testdata . Rule2 . Module ,
ErrorKey : testdata . RuleErrorKey2 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey2 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey2 . Description ,
Generic : testdata . RuleErrorKey2 . Generic ,
Reason : testdata . RuleErrorKey2 . Reason ,
Resolution : testdata . RuleErrorKey2 . Resolution ,
MoreInfo : testdata . RuleErrorKey2 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey2 . Impact , testdata . RuleErrorKey2 . Likelihood ) ,
Disabled : testdata . Rule2Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule2ExtraData ,
Tags : testdata . RuleErrorKey2 . Tags ,
} ,
}
Report3RulesWithDisabledData = [ ] types . RuleWithContentResponse {
{
RuleID : testdata . Rule1 . Module ,
ErrorKey : testdata . RuleErrorKey1 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey1 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ,
Disabled : testdata . Rule1Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule1ExtraData ,
Tags : testdata . RuleErrorKey1 . Tags ,
} ,
{
RuleID : testdata . Rule2 . Module ,
ErrorKey : testdata . RuleErrorKey2 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey2 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey2 . Description ,
Generic : testdata . RuleErrorKey2 . Generic ,
Reason : testdata . RuleErrorKey2 . Reason ,
Resolution : testdata . RuleErrorKey2 . Resolution ,
MoreInfo : testdata . RuleErrorKey2 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey2 . Impact , testdata . RuleErrorKey2 . Likelihood ) ,
Disabled : testdata . Rule2Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule2ExtraData ,
Tags : testdata . RuleErrorKey2 . Tags ,
} ,
{
RuleID : testdata . Rule5 . Module ,
ErrorKey : testdata . RuleErrorKey5 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey5 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey5 . Description ,
Generic : testdata . RuleErrorKey5 . Generic ,
Reason : testdata . RuleErrorKey5 . Reason ,
Resolution : testdata . RuleErrorKey5 . Resolution ,
MoreInfo : testdata . RuleErrorKey5 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey5 . Impact , testdata . RuleErrorKey5 . Likelihood ) ,
Disabled : testdata . Rule5Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule5ExtraData ,
Tags : testdata . RuleErrorKey5 . Tags ,
} ,
}
SmartProxyReportResponse3RulesWithOnlyOSD = struct {
Status string `json:"status"`
Report * types . SmartProxyReport `json:"report"`
} {
Status : "ok" ,
Report : & SmartProxyReport3RulesWithOnlyOSDNoAMSClient ,
}
SmartProxyReportResponse3RulesOnlyEnabled = struct {
Status string `json:"status"`
Report * types . SmartProxyReport `json:"report"`
} {
Status : "ok" ,
Report : & SmartProxyReport3RulesOnlyEnabledNoAMSClient ,
}
SmartProxyEmptyResponse = struct {
Status string `json:"status"`
Report * types . SmartProxyReport `json:"report"`
} {
Status : "ok" ,
Report : & SmartProxyReportEmptyCount2NoAMSClient ,
}
SmartProxyReportResponse3RulesAll = struct {
Status string `json:"status"`
Report * types . SmartProxyReport `json:"report"`
} {
Status : "ok" ,
Report : & SmartProxyReport3RulesWithDisabledNoAMSClient ,
}
SmartProxyReport3RulesWithOnlyOSDNoAMSClient = types . SmartProxyReport {
Meta : types . ReportResponseMeta {
DisplayName : string ( testdata . ClusterName ) ,
Count : 1 ,
LastCheckedAt : types . Timestamp ( testdata . LastCheckedAt . UTC ( ) . Format ( time . RFC3339 ) ) ,
} ,
Data : Report3RulesWithOnlyOSDData ,
}
SmartProxyReport3RulesOnlyEnabledNoAMSClient = types . SmartProxyReport {
Meta : types . ReportResponseMeta {
DisplayName : string ( testdata . ClusterName ) ,
Count : 2 ,
LastCheckedAt : types . Timestamp ( testdata . LastCheckedAt . UTC ( ) . Format ( time . RFC3339 ) ) ,
} ,
Data : Report3RulesOnlyEnabledData ,
}
SmartProxyReportEmptyCount2NoAMSClient = types . SmartProxyReport {
Meta : types . ReportResponseMeta {
DisplayName : string ( testdata . ClusterName ) ,
Count : 2 ,
LastCheckedAt : types . Timestamp ( testdata . LastCheckedAt . UTC ( ) . Format ( time . RFC3339 ) ) ,
} ,
Data : [ ] types . RuleWithContentResponse { } ,
}
SmartProxyReport3RulesWithDisabledNoAMSClient = types . SmartProxyReport {
Meta : types . ReportResponseMeta {
DisplayName : string ( testdata . ClusterName ) ,
Count : 3 ,
LastCheckedAt : types . Timestamp ( testdata . LastCheckedAt . UTC ( ) . Format ( time . RFC3339 ) ) ,
} ,
Data : Report3RulesWithDisabledData ,
}
GetContentResponse3Rules = struct {
Status string `json:"status"`
Rules [ ] ctypes . RuleContentV1 `json:"content"`
} {
Status : "ok" ,
Rules : [ ] ctypes . RuleContentV1 {
content . RuleContentToV1 ( & testdata . RuleContent1 ) ,
content . RuleContentToV1 ( & testdata . RuleContent2 ) ,
content . RuleContentToV1 ( & testdata . RuleContent3 ) ,
} ,
}
RuleContentInternal1 = ctypes . RuleContent {
Summary : testdata . Rule1 . Summary ,
Generic : testdata . Rule1 . Generic ,
Reason : testdata . Rule1 . Reason ,
Resolution : testdata . Rule1 . Resolution ,
MoreInfo : testdata . Rule1 . MoreInfo ,
Plugin : ctypes . RulePluginInfo {
Name : testdata . Rule1 . Name ,
NodeID : "" ,
ProductCode : "" ,
PythonModule : internalTestRuleModule ,
} ,
ErrorKeys : map [ string ] ctypes . RuleErrorKeyContent {
"ek1" : {
Summary : testdata . RuleErrorKey1 . Summary ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
Metadata : ctypes . ErrorKeyMetadata {
Description : testdata . RuleErrorKey1 . Description ,
Impact : ctypes . Impact {
Name : "test_impact" ,
Impact : testdata . RuleErrorKey1 . Impact ,
} ,
Likelihood : testdata . RuleErrorKey1 . Likelihood ,
PublishDate : testdata . RuleErrorKey1 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Tags : testdata . RuleErrorKey1 . Tags ,
Status : "active" ,
} ,
} ,
} ,
}
OverviewResponseRules123Enabled = struct {
Status string `json:"status"`
Overview map [ string ] interface { } `json:"overview"`
} {
Status : "ok" ,
Overview : map [ string ] interface { } {
"clusters_hit" : 1 ,
"hit_by_risk" : map [ string ] int {
"1" : 1 ,
"2" : 2 ,
} ,
"hit_by_tag" : map [ string ] int {
"openshift" : 1 ,
"osd_customer" : 1 ,
"service_availability" : 1 ,
} ,
} ,
}
OverviewResponseManagedRules = struct {
Status string `json:"status"`
Overview map [ string ] interface { } `json:"overview"`
} {
Status : "ok" ,
Overview : map [ string ] interface { } {
"clusters_hit" : 1 ,
"hit_by_risk" : map [ string ] int {
"1" : 1 ,
} ,
"hit_by_tag" : map [ string ] int {
"openshift" : 1 ,
"osd_customer" : 1 ,
"service_availability" : 1 ,
} ,
} ,
}
OverviewResponseRule1DisabledRule2Enabled = struct {
Status string `json:"status"`
Overview map [ string ] interface { } `json:"overview"`
} {
Status : "ok" ,
Overview : map [ string ] interface { } {
"clusters_hit" : 1 ,
"hit_by_risk" : map [ string ] int {
"2" : 2 ,
} ,
"hit_by_tag" : map [ string ] int { } ,
} ,
}
OverviewResponseRule1EnabledRule2Disabled = struct {
Status string `json:"status"`
Overview map [ string ] interface { } `json:"overview"`
} {
Status : "ok" ,
Overview : map [ string ] interface { } {
"clusters_hit" : 1 ,
"hit_by_risk" : map [ string ] int {
"1" : 1 ,
"2" : 1 ,
} ,
"hit_by_tag" : map [ string ] int {
"openshift" : 1 ,
"osd_customer" : 1 ,
"service_availability" : 1 ,
} ,
} ,
}
OverviewResponseRule5DisabledRules1And2Enabled = struct {
Status string `json:"status"`
Overview map [ string ] interface { } `json:"overview"`
} {
Status : "ok" ,
Overview : map [ string ] interface { } {
"clusters_hit" : 1 ,
"hit_by_risk" : map [ string ] int {
"1" : 1 ,
"2" : 1 ,
} ,
"hit_by_tag" : map [ string ] int {
"openshift" : 1 ,
"osd_customer" : 1 ,
"service_availability" : 1 ,
} ,
} ,
}
OverviewResponsePostEndpoint = struct {
Status string `json:"status"`
Overview map [ string ] interface { } `json:"overview"`
} {
Status : "ok" ,
Overview : map [ string ] interface { } {
"clusters_hit" : 2 ,
"hit_by_risk" : map [ string ] int {
"1" : 1 ,
"2" : 2 ,
} ,
"hit_by_tag" : map [ string ] int {
"openshift" : 1 ,
"osd_customer" : 1 ,
"service_availability" : 1 ,
} ,
} ,
}
OverviewResponsePostEndpointRule1Disabled = struct {
Status string `json:"status"`
Overview map [ string ] interface { } `json:"overview"`
} {
Status : "ok" ,
Overview : map [ string ] interface { } {
"clusters_hit" : 2 ,
"hit_by_risk" : map [ string ] int {
"2" : 2 ,
} ,
"hit_by_tag" : map [ string ] int { } ,
} ,
}
OverviewResponsePostEndpointRule2Disabled = struct {
Status string `json:"status"`
Overview map [ string ] interface { } `json:"overview"`
} {
Status : "ok" ,
Overview : map [ string ] interface { } {
"clusters_hit" : 2 ,
"hit_by_risk" : map [ string ] int {
"1" : 1 ,
} ,
"hit_by_tag" : map [ string ] int {
"openshift" : 1 ,
"osd_customer" : 1 ,
"service_availability" : 1 ,
} ,
} ,
}
SmartProxyReportResponse3SingleRule = struct {
Status string `json:"status"`
Report types . RuleWithContentResponse `json:"report"`
} {
Status : "ok" ,
Report : types . RuleWithContentResponse {
RuleID : testdata . Rule1 . Module ,
ErrorKey : testdata . RuleErrorKey1 . ErrorKey ,
CreatedAt : testdata . RuleErrorKey1 . PublishDate . UTC ( ) . Format ( time . RFC3339 ) ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
TotalRisk : calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ,
Disabled : testdata . Rule1Disabled ,
UserVote : types . UserVoteNone ,
TemplateData : testdata . Rule1ExtraData ,
Tags : testdata . RuleErrorKey1 . Tags ,
} ,
}
SmartProxyReportResponse3NoRuleFound = struct {
Status string `json:"status"`
} {
Status : "Rule was not found" ,
}
GetRecommendationsResponse1Rule2Cluster = struct {
Status string `json:"status"`
Recommendations [ ] types . RecommendationListView `json:"recommendations"`
} {
Status : "ok" ,
Recommendations : [ ] types . RecommendationListView {
{
RuleID : testdata . Rule1CompositeID ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
PublishDate : testdata . RuleErrorKey1 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey1 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey1 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey1 . Likelihood ) ,
Tags : testdata . RuleErrorKey1 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 2 ,
} ,
} ,
}
GetRecommendationsResponse2Rules0Clusters = struct {
Status string `json:"status"`
Recommendations [ ] types . RecommendationListView `json:"recommendations"`
} {
Status : "ok" ,
Recommendations : [ ] types . RecommendationListView {
{
RuleID : testdata . Rule1CompositeID ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
PublishDate : testdata . RuleErrorKey1 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey1 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey1 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey1 . Likelihood ) ,
Tags : testdata . RuleErrorKey1 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 0 ,
} ,
{
RuleID : testdata . Rule2CompositeID ,
Description : testdata . RuleErrorKey2 . Description ,
Generic : testdata . RuleErrorKey2 . Generic ,
PublishDate : testdata . RuleErrorKey2 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey2 . Impact , testdata . RuleErrorKey2 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey2 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey2 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey2 . Likelihood ) ,
Tags : testdata . RuleErrorKey2 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 0 ,
} ,
} ,
}
GetRecommendationsResponse2Rules1Disabled1Acked = struct {
Status string `json:"status"`
Recommendations [ ] types . RecommendationListView `json:"recommendations"`
} {
Status : "ok" ,
Recommendations : [ ] types . RecommendationListView {
{
RuleID : testdata . Rule1CompositeID ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
PublishDate : testdata . RuleErrorKey1 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey1 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey1 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey1 . Likelihood ) ,
Tags : testdata . RuleErrorKey1 . Tags ,
Disabled : true ,
ImpactedClustersCnt : 2 ,
} ,
{
RuleID : testdata . Rule2CompositeID ,
Description : testdata . RuleErrorKey2 . Description ,
Generic : testdata . RuleErrorKey2 . Generic ,
PublishDate : testdata . RuleErrorKey2 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey2 . Impact , testdata . RuleErrorKey2 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey2 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey2 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey2 . Likelihood ) ,
Tags : testdata . RuleErrorKey2 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 1 ,
} ,
} ,
}
GetRecommendationsResponse2Rules2Clusters = struct {
Status string `json:"status"`
Recommendations [ ] types . RecommendationListView `json:"recommendations"`
} {
Status : "ok" ,
Recommendations : [ ] types . RecommendationListView {
{
RuleID : testdata . Rule1CompositeID ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
PublishDate : testdata . RuleErrorKey1 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey1 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey1 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey1 . Likelihood ) ,
Tags : testdata . RuleErrorKey1 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 2 ,
} ,
{
RuleID : testdata . Rule2CompositeID ,
Description : testdata . RuleErrorKey2 . Description ,
Generic : testdata . RuleErrorKey2 . Generic ,
PublishDate : testdata . RuleErrorKey2 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey2 . Impact , testdata . RuleErrorKey2 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey2 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey2 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey2 . Likelihood ) ,
Tags : testdata . RuleErrorKey2 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 1 ,
} ,
} ,
}
GetRecommendationsResponse2Rules2Clusters1Managed = struct {
Status string `json:"status"`
Recommendations [ ] types . RecommendationListView `json:"recommendations"`
} {
Status : "ok" ,
Recommendations : [ ] types . RecommendationListView {
{
RuleID : testdata . Rule1CompositeID ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
PublishDate : testdata . RuleErrorKey1 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey1 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey1 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey1 . Likelihood ) ,
Tags : testdata . RuleErrorKey1 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 2 ,
} ,
{
RuleID : testdata . Rule2CompositeID ,
Description : testdata . RuleErrorKey2 . Description ,
Generic : testdata . RuleErrorKey2 . Generic ,
PublishDate : testdata . RuleErrorKey2 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey2 . Impact , testdata . RuleErrorKey2 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey2 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey2 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey2 . Likelihood ) ,
Tags : testdata . RuleErrorKey2 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 0 ,
} ,
} ,
}
GetRecommendationsResponse3Rules1Cluster = struct {
Status string `json:"status"`
Recommendations [ ] types . RecommendationListView `json:"recommendations"`
} {
Status : "ok" ,
Recommendations : [ ] types . RecommendationListView {
{
RuleID : testdata . Rule1CompositeID ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
PublishDate : testdata . RuleErrorKey1 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey1 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey1 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey1 . Likelihood ) ,
Tags : testdata . RuleErrorKey1 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 1 ,
} ,
{
RuleID : testdata . Rule2CompositeID ,
Description : testdata . RuleErrorKey2 . Description ,
Generic : testdata . RuleErrorKey2 . Generic ,
PublishDate : testdata . RuleErrorKey2 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey2 . Impact , testdata . RuleErrorKey2 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey2 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey2 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey2 . Likelihood ) ,
Tags : testdata . RuleErrorKey2 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 0 ,
} ,
{
RuleID : testdata . Rule3CompositeID ,
Description : testdata . RuleErrorKey3 . Description ,
Generic : testdata . RuleErrorKey3 . Generic ,
PublishDate : testdata . RuleErrorKey3 . PublishDate ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey3 . Impact , testdata . RuleErrorKey3 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey3 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey3 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey3 . Likelihood ) ,
Tags : testdata . RuleErrorKey3 . Tags ,
Disabled : false ,
ImpactedClustersCnt : 0 ,
} ,
} ,
}
GetRecommendationsResponse0Rules = struct {
Status string `json:"status"`
Recommendations [ ] types . RecommendationListView `json:"recommendations"`
} {
Status : "ok" ,
Recommendations : [ ] types . RecommendationListView { } ,
}
GetRuleContentRecommendationContent1 = struct {
Content types . RecommendationContent `json:"content"`
Groups [ ] groups . Group `json:"groups"`
Status string `json:"status"`
} {
Content : types . RecommendationContent {
RuleSelector : ctypes . RuleSelector ( testdata . Rule1CompositeID ) ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ) ,
Impact : uint8 ( testdata . RuleErrorKey1 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey1 . Likelihood ) ,
PublishDate : testdata . RuleErrorKey1 . PublishDate ,
Tags : testdata . RuleErrorKey1 . Tags ,
} ,
Groups : [ ] groups . Group { } ,
Status : "ok" ,
}
GetRuleContentRecommendationContentWithUserData1 = struct {
Content types . RecommendationContentUserData `json:"content"`
Groups [ ] groups . Group `json:"groups"`
Status string `json:"status"`
} {
Content : types . RecommendationContentUserData {
RuleSelector : ctypes . RuleSelector ( testdata . Rule1CompositeID ) ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey1 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey1 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey1 . Likelihood ) ,
PublishDate : testdata . RuleErrorKey1 . PublishDate ,
Rating : types . UserVoteNone ,
AckedCount : 0 ,
Tags : testdata . RuleErrorKey1 . Tags ,
Disabled : false ,
} ,
Groups : [ ] groups . Group { } ,
Status : "ok" ,
}
GetRuleContentRecommendationContentWithUserData2RatingLike = struct {
Content types . RecommendationContentUserData `json:"content"`
Groups [ ] groups . Group `json:"groups"`
Status string `json:"status"`
} {
Content : types . RecommendationContentUserData {
RuleSelector : ctypes . RuleSelector ( testdata . Rule1CompositeID ) ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey1 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey1 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey1 . Likelihood ) ,
PublishDate : testdata . RuleErrorKey1 . PublishDate ,
Rating : types . UserVoteLike ,
AckedCount : 0 ,
Tags : testdata . RuleErrorKey1 . Tags ,
Disabled : false ,
} ,
Groups : [ ] groups . Group { } ,
Status : "ok" ,
}
GetRuleContentRecommendationContentWithUserData3RatingDislike = struct {
Content types . RecommendationContentUserData `json:"content"`
Groups [ ] groups . Group `json:"groups"`
Status string `json:"status"`
} {
Content : types . RecommendationContentUserData {
RuleSelector : ctypes . RuleSelector ( testdata . Rule1CompositeID ) ,
Description : testdata . RuleErrorKey1 . Description ,
Generic : testdata . RuleErrorKey1 . Generic ,
Reason : testdata . RuleErrorKey1 . Reason ,
Resolution : testdata . RuleErrorKey1 . Resolution ,
MoreInfo : testdata . RuleErrorKey1 . MoreInfo ,
TotalRisk : uint8 ( calculateTotalRisk ( testdata . RuleErrorKey1 . Impact , testdata . RuleErrorKey1 . Likelihood ) ) ,
ResolutionRisk : uint8 ( testdata . RuleErrorKey1 . ResolutionRisk ) ,
Impact : uint8 ( testdata . RuleErrorKey1 . Impact ) ,
Likelihood : uint8 ( testdata . RuleErrorKey1 . Likelihood ) ,
PublishDate : testdata . RuleErrorKey1 . PublishDate ,
Rating : types . UserVoteDislike ,
AckedCount : 0 ,
Tags : testdata . RuleErrorKey1 . Tags ,
Disabled : false ,
} ,
Groups : [ ] groups . Group { } ,
Status : "ok" ,
}
GetClustersResponse0Clusters = struct {
Meta map [ string ] interface { } `json:"meta"`
Status string `json:"status"`
Clusters [ ] types . ClusterListView `json:"data"`
} {
Meta : map [ string ] interface { } {
"count" : 0 ,
} ,
Status : "ok" ,
Clusters : [ ] types . ClusterListView { } ,
}
|
TestInfoEndpointNoAuthToken checks that the info endpoint can be accessed without authenticating
|
func TestInfoEndpointNoAuthToken ( t * testing . T ) {
t . Run ( "test the info endpoint v1" , func ( t * testing . T ) {
helpers . AssertAPIRequest ( t , & helpers . DefaultServerConfig , & helpers . DefaultServicesConfig , nil , nil , nil , & helpers . APIRequest {
Method : http . MethodGet ,
Endpoint : server . InfoEndpoint ,
} , & helpers . APIResponse {
StatusCode : http . StatusOK ,
} )
} )
t . Run ( "test the info endpoint v2" , func ( t * testing . T ) {
helpers . AssertAPIv2Request ( t , & helpers . DefaultServerConfig , & helpers . DefaultServicesConfig , nil , nil , nil , & helpers . APIRequest {
Method : http . MethodGet ,
Endpoint : server . InfoEndpoint ,
} , & helpers . APIResponse {
StatusCode : http . StatusOK ,
} )
} )
}
func ruleIDsChecker ( t testing . TB , expected , got [ ] byte ) {
type Response struct {
Status string `json:"status"`
Rules [ ] string `json:"rules"`
}
var expectedResp , gotResp Response
if err := json . Unmarshal ( expected , & expectedResp ) ; err != nil {
err = fmt . Errorf ( `"expected" is not JSON. value = "%v", err = "%v"` , expected , err )
helpers . FailOnError ( t , err )
}
if err := json . Unmarshal ( got , & gotResp ) ; err != nil {
err = fmt . Errorf ( `"got" is not JSON. value = "%v", err = "%v"` , got , err )
helpers . FailOnError ( t , err )
}
assert . ElementsMatch ( t , expectedResp . Rules , gotResp . Rules )
}
func ruleInContentChecker ( t testing . TB , expected , got [ ] byte ) {
type Response struct {
Status string `json:"string"`
Content [ ] types . RuleContentV1
}
var expectedResp Response
var gotResp Response
if err := json . Unmarshal ( expected , & expectedResp ) ; err != nil {
err = fmt . Errorf ( `"expected" is not JSON. value = "%v", err = "%v"` , expected , err )
helpers . FailOnError ( t , err )
}
if err := json . Unmarshal ( got , & gotResp ) ; err != nil {
err = fmt . Errorf ( `"got" is not JSON. value = "%v", err = "%v"` , string ( got ) , err )
helpers . FailOnError ( t , err )
}
assert . ElementsMatch ( t , expectedResp . Content , gotResp . Content )
}
func recommendationInResponseChecker ( t testing . TB , expected , got [ ] byte ) {
type Response struct {
Status string `json:"status"`
Recommendations [ ] types . RecommendationListView `json:"recommendations"`
}
var expectedResp , gotResp Response
if err := json . Unmarshal ( expected , & expectedResp ) ; err != nil {
err = fmt . Errorf ( `"expected" is not JSON. value = "%v", err = "%v"` , expected , err )
helpers . FailOnError ( t , err )
}
if err := json . Unmarshal ( got , & gotResp ) ; err != nil {
err = fmt . Errorf ( `"got" is not JSON. value = "%v", err = "%v"` , got , err )
helpers . FailOnError ( t , err )
}
assert . ElementsMatch ( t , expectedResp . Recommendations , gotResp . Recommendations )
}
func clusterInResponseChecker ( t testing . TB , expected , got [ ] byte ) {
type Response struct {
Meta map [ string ] interface { } `json:"meta"`
Status string `json:"status"`
Clusters [ ] types . ClusterListView `json:"data"`
}
var expectedResp , gotResp Response
if err := json . Unmarshal ( expected , & expectedResp ) ; err != nil {
err = fmt . Errorf ( `"expected" is not JSON. value = "%v", err = "%v"` , expected , err )
helpers . FailOnError ( t , err )
}
if err := json . Unmarshal ( got , & gotResp ) ; err != nil {
err = fmt . Errorf ( `"got" is not JSON. value = "%v", err = "%v"` , got , err )
helpers . FailOnError ( t , err )
}
assert . ElementsMatch ( t , expectedResp . Clusters , gotResp . Clusters )
}
func ackInResponseChecker ( t testing . TB , expected , got [ ] byte ) {
var expectedResp , gotResp ctypes . AcknowledgementsResponse
if err := json . Unmarshal ( expected , & expectedResp ) ; err != nil {
err = fmt . Errorf ( `"expected" is not JSON. value = "%v", err = "%v"` , expected , err )
helpers . FailOnError ( t , err )
}
if err := json . Unmarshal ( got , & gotResp ) ; err != nil {
err = fmt . Errorf ( `"got" is not JSON. value = "%v", err = "%v"` , got , err )
helpers . FailOnError ( t , err )
}
assert . ElementsMatch ( t , expectedResp . Data , gotResp . Data )
assert . Equal ( t , expectedResp . Metadata . Count , gotResp . Metadata . Count )
}
func TestFillImpacted ( t * testing . T ) {
var response [ ] types . RuleWithContentResponse
var aggregatorReport [ ] ctypes . RuleOnReport
resp0 := types . RuleWithContentResponse {
RuleID : "rid0" ,
ErrorKey : "ek0" ,
}
resp1 := types . RuleWithContentResponse {
RuleID : "rid1" ,
ErrorKey : "ek1" ,
}
resp2 := types . RuleWithContentResponse {
RuleID : "rid2" ,
ErrorKey : "ek2" ,
}
respNa := types . RuleWithContentResponse {
RuleID : "111" ,
ErrorKey : "111" ,
}
report0 := ctypes . RuleOnReport {
Module : "rid0" ,
ErrorKey : "ek0" ,
CreatedAt : types . Timestamp ( time . Now ( ) . UTC ( ) . Format ( time . RFC3339 ) ) ,
}
report1 := ctypes . RuleOnReport {
Module : "rid1" ,
ErrorKey : "ek1" ,
CreatedAt : types . Timestamp ( time . Time { } . UTC ( ) . Format ( time . RFC3339 ) ) ,
}
report2 := ctypes . RuleOnReport {
Module : "rid2" ,
ErrorKey : "ek2" ,
CreatedAt : "wrong time format" ,
}
reportNa := ctypes . RuleOnReport {
Module : "000" ,
ErrorKey : "000" ,
}
response = append ( response , resp0 , resp1 , resp2 , respNa )
aggregatorReport = append ( aggregatorReport , report0 , report1 , report2 , reportNa )
server . FillImpacted ( response , aggregatorReport )
assert . Equal ( t , response [ 0 ] . Impacted , report0 . CreatedAt )
assert . True ( t , len ( response [ 1 ] . Impacted ) == 0 )
assert . True ( t , len ( response [ 2 ] . Impacted ) == 0 )
jsonResp , err := json . Marshal ( response )
assert . NoError ( t , err )
assert . NotContains ( t , string ( jsonResp ) , "0001-01-01T00:00:00Z" )
}
|