This commit is contained in:
2020-04-09 19:26:00 +00:00
parent e1c13b7f8e
commit 6dd2f88276

View File

@@ -40,7 +40,7 @@ namespace raven_integration
D.login = Util.Uniquify("LOGIN");
D.password = Util.Uniquify("PASSWORD");
D.usertype = 1;
D.userType = 3;//non scheduleable
a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
@@ -57,7 +57,7 @@ namespace raven_integration
D.login = Util.Uniquify("LOGIN");
D.password = Util.Uniquify("PASSWORD");
D.usertype = 1;
D.userType = 3;//non scheduleable
a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
@@ -132,35 +132,14 @@ namespace raven_integration
//even though the record exists
//Just re-run the above search exactly but with a no rights to full User or Widget role instead
//Only BizAdmin* roles can read a full user record but anyone should be able to see names
//Only BizAdmin* roles can read a full user record
//This search should return zero items
a = await Util.PostAsync("Search", await Util.GetTokenAsync("SubContractorLimited"), SearchParameters.ToString());
Util.ValidateDataReturnResponseOk(a);
((JArray)a.ObjectResponse["data"]["searchResults"]).Count.Should().Be(0, "User with no rights should not see any results in body search");
//NAME ONLY SEARCH SHOULD WORK WITH NO RIGHTS TO READ FULL RECORD
//repeat same search but with nameOnly = true and should return at two records at least but not any of the body ones
SearchParameters = new JObject();
SearchParameters.phrase = TEST_SEARCH_PHRASE;
SearchParameters.nameOnly = true;
SearchParameters.typeOnly = 0;//no type
SearchParameters.maxResults = 0;
a = await Util.PostAsync("Search", await Util.GetTokenAsync("SubContractorLimited"), SearchParameters.ToString());
Util.ValidateDataReturnResponseOk(a);
((JArray)a.ObjectResponse["data"]["searchResults"]).Count.Should().BeGreaterOrEqualTo(2);
//Check that list does *not* include the notes only records
MatchingIdList = new List<long>();
v = ((JArray)a.ObjectResponse["data"]["searchResults"]);
foreach (JObject j in v)
{
MatchingIdList.Add(j["id"].Value<long>());
}
MatchingIdList.Should().NotContain(MatchWidgetInNotesId, "ShouldNotContainMatchWidgetInNotesId");
MatchingIdList.Should().Contain(MatchWidgetInNameId, "ShouldContainMatchWidgetInNameId");
MatchingIdList.Should().NotContain(MatchUserInNotesId, "ShouldContainMatchUserInNotesId");
MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId");
MatchingIdList.Should().NotContain(MatchNothingWidgetId, "ShouldNotContainThirdWidget");
}//eot
@@ -194,7 +173,7 @@ namespace raven_integration
D.login = Util.Uniquify("LOGIN");
D.password = Util.Uniquify("PASSWORD");
D.usertype = 1;
D.userType = 3;//non scheduleable
D.customFields = Util.UserRequiredCustomFieldsJsonString();
@@ -258,7 +237,7 @@ namespace raven_integration
D.login = Util.Uniquify("LOGIN");
D.password = Util.Uniquify("PASSWORD");
D.usertype = 1;
D.userType = 3;//non scheduleable
D.customFields = Util.UserRequiredCustomFieldsJsonString();
@@ -298,9 +277,9 @@ namespace raven_integration
[Fact]
public async void WildCardContainsSearchShouldWork()
public async void SearchAndExtractShouldWork()
{
const string TEST_SEARCH_PHRASE = "*cast* goose";
const string TEST_SEARCH_PHRASE = "cast goose";
//CREATE A WIDGET
dynamic D = new JObject();
@@ -324,7 +303,7 @@ namespace raven_integration
D.login = Util.Uniquify("LOGIN");
D.password = Util.Uniquify("PASSWORD");
D.usertype = 1;
D.userType = 3;//non scheduleable
D.customFields = Util.UserRequiredCustomFieldsJsonString();
@@ -358,6 +337,14 @@ namespace raven_integration
MatchingIdList.Should().Contain(MatchWidgetInNotesId, "ShouldContainMatchWidgetInNotesId");
MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId");
//Ensure excerpt works and contains the search phrase
// /Search/Info/2/1?phrase=we&max=200
a = await Util.GetAsync($"Search/Info/2/{MatchWidgetInNotesId}?phrase={TEST_SEARCH_PHRASE}&max=200", await Util.GetTokenAsync("manager", "l3tm3in"));
Util.ValidateDataReturnResponseOk(a);
a.ObjectResponse["data"].Value<string>().Should().Contain(TEST_SEARCH_PHRASE.Split(" ")[0]);
a.ObjectResponse["data"].Value<string>().Should().Contain(TEST_SEARCH_PHRASE.Split(" ")[1]);
}//eot
@@ -423,7 +410,7 @@ namespace raven_integration
D.login = Util.Uniquify("LOGIN");
D.password = Util.Uniquify("PASSWORD");
D.usertype = 1;
D.userType = 3;//non scheduleable
D.customFields = Util.UserRequiredCustomFieldsJsonString();
@@ -585,6 +572,7 @@ namespace raven_integration
MatchingIdList.Should().Contain(MatchWidgetInSerialId, "ShouldContainMatchWidgetInSerialId");
}//eot
@@ -625,7 +613,7 @@ Likely fix is to force order to most recent or simply to delete after test so th
//CREATE A WIDGET
dynamic D = new JObject();
D.name = Util.Uniquify("CUSTOMFIELD search test WIDGET");
D.customFields = dCustomField.ToString();
D.customFields = dCustomField.ToString();
D.dollarAmount = 1.11m;
D.active = true;
D.usertype = 1;
@@ -650,7 +638,7 @@ Likely fix is to force order to most recent or simply to delete after test so th
((JArray)a.ObjectResponse["data"]["searchResults"]).Count.Should().BeGreaterOrEqualTo(1);//might be a successive run and still have some left so account for more than one return
//Turn the list into an array of id's
var v = ((JArray)a.ObjectResponse["data"]["searchResults"]);
var v = ((JArray)a.ObjectResponse["data"]["searchResults"]);
List<long> MatchingIdList = new List<long>();
foreach (JObject j in v)
{
@@ -661,7 +649,7 @@ Likely fix is to force order to most recent or simply to delete after test so th
MatchingIdList.Should().Contain(MatchingWidgetId, "ShouldContainMatchingCustomFieldWidgetId");
//Now delete the newly created one so the list doesn't build up and prevent this test from working in big runs...
//DELETE
//DELETE
ApiResponse DELETETestResponse = await Util.DeleteAsync("Widget/" + MatchingWidgetId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);