Add GraphQL Schema matching (#964)

* Add GrapQLMatcher

* tests

* x

* .

* .

* RequestMessageGraphQLMatcher

* .

* more tests

* tests

* ...

* ms

* .

* more tests

* GraphQL.NET !!!

* .

* executionResult

* nw

* sonarcloud
This commit is contained in:
Stef Heyenrath
2023-07-07 21:43:46 +02:00
committed by GitHub
parent 9443e4f071
commit b495eb83b1
22 changed files with 907 additions and 52 deletions

View File

@@ -0,0 +1,29 @@
{
Guid: Guid_1,
UpdatedAt: DateTime_1,
Title: ,
Description: ,
Priority: 42,
Request: {
Body: {
Matcher: {
Name: GraphQLMatcher,
Pattern:
type Query {
greeting:String
students:[Student]
studentById(id:ID!):Student
}
type Student {
id:ID!
firstName:String
lastName:String
fullName:String
}
}
}
},
Response: {},
UseWebhooksFireAndForget: false
}

View File

@@ -0,0 +1,20 @@
{
Guid: Guid_1,
UpdatedAt: DateTime_1,
Title: ,
Description: ,
Priority: 42,
Request: {
Path: {
Matchers: [
{
Name: WildcardMatcher,
Pattern: 1.2.3.4,
IgnoreCase: false
}
]
}
},
Response: {},
UseWebhooksFireAndForget: false
}

View File

@@ -260,7 +260,7 @@ public partial class MappingConverterTests
}
[Fact]
public Task ToMappingModel_WithDelayAsMilliSeconds_ReturnsCorrectModel()
public Task ToMappingModel_WithDelay_ReturnsCorrectModel()
{
// Assign
var delay = 1000;
@@ -343,5 +343,56 @@ public partial class MappingConverterTests
// Verify
return Verifier.Verify(model);
}
[Fact]
public Task ToMappingModel_Request_WithClientIP_ReturnsCorrectModel()
{
// Arrange
var request = Request.Create().WithClientIP("1.2.3.4");
var response = Response.Create();
var mapping = new Mapping(_guid, _updatedAt, string.Empty, string.Empty, null, _settings, request, response, 42, null, null, null, null, null, false, null, null, null);
// Act
var model = _sut.ToMappingModel(mapping);
// Assert
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
}
#if GRAPHQL
[Fact]
public Task ToMappingModel_Request_WithBodyAsGraphQLSchema_ReturnsCorrectModel()
{
// Arrange
var schema = @"
type Query {
greeting:String
students:[Student]
studentById(id:ID!):Student
}
type Student {
id:ID!
firstName:String
lastName:String
fullName:String
}";
var request = Request.Create().WithBodyAsGraphQLSchema(schema);
var response = Response.Create();
var mapping = new Mapping(_guid, _updatedAt, string.Empty, string.Empty, null, _settings, request, response, 42, null, null, null, null, null, false, null, null, null);
// Act
var model = _sut.ToMappingModel(mapping);
// Assert
model.Should().NotBeNull();
// Verify
return Verifier.Verify(model);
}
#endif
}
#endif