Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing unintended update to GraphQL operation when updating REST methods #1555

Merged
merged 215 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
d12ad88
Removing the old config files and cleaning the project out
aaronpowell Mar 31, 2023
def1dcf
initial import of the new config types
aaronpowell Mar 31, 2023
3e7ccab
accidentally deleted that type
aaronpowell Apr 3, 2023
589ebcd
Some refactors in preperation of working on the tests
aaronpowell Apr 3, 2023
48c8ead
Started a new test class for the parsing of the config file
aaronpowell Apr 3, 2023
5b0c22e
Porting the service startup to new config structure
aaronpowell Apr 3, 2023
a7baa6a
Adding readable static for default REST path prefix
aaronpowell Apr 3, 2023
a54c0c1
Implementing the config validator
aaronpowell Apr 4, 2023
db9be8d
Uplifing the AuthorizationResolver
aaronpowell Apr 4, 2023
b69a4c6
Fixing converter after making field non-null
aaronpowell Apr 4, 2023
da686f5
Making exclude fields for an action default to empty hashset
aaronpowell Apr 4, 2023
f1e423a
Working through compiler errors
aaronpowell Apr 4, 2023
8be02cb
last of the compile errors in the core service
aaronpowell Apr 13, 2023
816a1a9
Fixing loading the config based on the ASPNETCORE_ENVIRONMENT
aaronpowell Apr 13, 2023
86d5e46
Getting CLI project to compile
aaronpowell Apr 14, 2023
6f25196
Created cli launch profile for init mssql config
aaronpowell Apr 14, 2023
e5e42f6
Fixed problem in how entities were serialized
aaronpowell Apr 14, 2023
a6ca6fd
Entities is an object not an array
aaronpowell Apr 14, 2023
a35fcc9
Testing if we can add entities with a new launch command
aaronpowell Apr 14, 2023
3317e5a
Refactoring the init tests, introducing snapshot testing
aaronpowell Apr 21, 2023
20d391c
Adding tests for AddEntity on the CLI
aaronpowell Apr 22, 2023
4dfe671
Update entity tests refactored
aaronpowell Apr 22, 2023
7e4b6bb
Implementing e2e tests for the CLI
aaronpowell Apr 28, 2023
6f132a9
Implementing the utils tests with some refactors of the test to make …
aaronpowell Apr 28, 2023
fb6ca7a
Refactoring Service.Tests to compile with new config
aaronpowell May 1, 2023
df3303d
Fixing tests for GraphQL Mutation builder
aaronpowell May 1, 2023
da34a2a
Fixing GraphQL Builder query tests
aaronpowell May 1, 2023
71ba1e4
Fixing SQL schema converter tests
aaronpowell May 1, 2023
9f23567
Initialising a config for db exception parser tests
aaronpowell May 1, 2023
279396c
Proper serialization of the JSON config
aaronpowell May 1, 2023
7cbe6f9
SQL Query executor tests updated
aaronpowell May 1, 2023
86cd881
This test should read the config from disk since it connects to the DB
aaronpowell May 2, 2023
325389b
Refactoring the connection string parsing tests
aaronpowell May 2, 2023
a2dd947
Improving the Entity REST option deserialization
aaronpowell May 2, 2023
aefb744
More decoupling of tests from static/shared state
aaronpowell May 2, 2023
bd410ad
Fixing an expectation on how the config was loaded
aaronpowell May 2, 2023
aa58d83
Changing how the JSON deserialization is handled
aaronpowell May 2, 2023
a291a31
Fixing the ConfigValidator tests
aaronpowell May 2, 2023
9c9e0cb
Fixing how to make a mock RuntimeConfigProvider
aaronpowell May 2, 2023
804b909
Making the runtime smarter about what file to load
aaronpowell May 2, 2023
15e30bb
Found problem in serialization of EntityGraphQLOptions
aaronpowell May 2, 2023
9488bf0
Refactoring the Cosmos tests
aaronpowell May 3, 2023
a188248
Fixing mapping for singular GraphQL names
aaronpowell May 3, 2023
18544d2
Fixing some spelling mistakes
aaronpowell May 3, 2023
39bd25e
Reverting the automatic singularization of GraphQL entities as that w…
aaronpowell May 3, 2023
c145799
Fixing some problems in the CLI tests.
aaronpowell May 3, 2023
a5796fe
Update snapshots to reflect the recent refactoring
aaronpowell May 3, 2023
01b9ea1
ensuring snapshots folder is included
aaronpowell May 3, 2023
5fb1977
Formatting code to meet standards
aaronpowell May 3, 2023
6c0ec55
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell May 3, 2023
9ad3420
TEMPORARY COMMIT
aaronpowell May 3, 2023
1aa102e
Reverting temporary commit
aaronpowell May 3, 2023
00321aa
Fixing compile errors from the merge
aaronpowell May 3, 2023
a23eff3
Result of a bad merge - didn't provide dbObjects
aaronpowell May 3, 2023
7bc18ad
null handling permissions and setting sproc params
aaronpowell May 3, 2023
9d0a91e
WIP
aaronpowell May 4, 2023
5ea4f8c
Merge branch 'tmp' into aaronpowell/new-config-engine
aaronpowell May 4, 2023
5efe7ac
Fixing compiler error and namespacing
aaronpowell May 4, 2023
20d922c
Code formatting
aaronpowell May 4, 2023
90e52e2
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell May 4, 2023
7a62f05
Fixing some compiler errors from merge
aaronpowell May 4, 2023
0b0b222
Fixing CORS test and making it a snapshot test
aaronpowell May 4, 2023
f3fe6e9
Flipping the tests so when REST or GraphQL CLI options are
aaronpowell May 4, 2023
9f54391
Updating snapshots to reflect new defaults in REST/GraphQL
aaronpowell May 4, 2023
dcf5b23
Renaming the converter factory
aaronpowell May 4, 2023
aa8a002
Improving how env var replacement happens on deserialization
aaronpowell May 4, 2023
35a42d2
Fixing some locations where we shouldn't be deserializing with env re…
aaronpowell May 5, 2023
bbf1130
adding some useful messages to Assert.IsTrue failures
aaronpowell May 5, 2023
1c8585d
Enabling strict mode for snapshooter to avoid generating snapshots on…
aaronpowell May 5, 2023
46d00ca
Default EntityActionFields should be null as they aren't required
aaronpowell May 8, 2023
82e3560
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell May 8, 2023
409c267
Reintroducing the regressed functionality around events on config loa…
aaronpowell May 8, 2023
b7bf774
Adding missing snapshots and fixing env loading
aaronpowell May 8, 2023
3715cdc
Removing old cold and unsetting fake connection string from env vars
aaronpowell May 8, 2023
5fb961e
Ensuring DAB env vars are properly cleaned up after test runs
aaronpowell May 9, 2023
ed4d382
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell May 9, 2023
a2b2b9e
Fixing bad merge
aaronpowell May 9, 2023
5bd313b
Fixing snapshot test
aaronpowell May 9, 2023
8f64458
Improving how we ignore connection strings in snapshots
aaronpowell May 9, 2023
4da577e
really basic diff displayer to help debugging
aaronpowell May 11, 2023
6c353c0
snapshots should be in build output maybe
aaronpowell May 11, 2023
06ea3f3
file name doesn't include path
aaronpowell May 11, 2023
6bc70c1
more work on the simple diff engine
aaronpowell May 11, 2023
4007897
really verbose error message
aaronpowell May 11, 2023
cff3dfd
fixing snapshots to match how config is formatted when tests run
aaronpowell May 11, 2023
ab6c9e9
cleaning up usings
aaronpowell May 11, 2023
594fcf3
regenerating the cosmos config using the cli
aaronpowell May 11, 2023
3638234
More improvements to the default CosmosDB_NoSQL config
aaronpowell May 11, 2023
a0ff6ae
Disabling REST at an entity for CosmosDB
aaronpowell May 11, 2023
9a82332
Fixing cosmosdb deserialization snapshot
aaronpowell May 11, 2023
9c563fc
Fixing formatting
aaronpowell May 11, 2023
bdda7ea
Maybe making the diff display a bit better
aaronpowell May 11, 2023
541c68b
Updated snapshots
aaronpowell May 11, 2023
08fbf38
Fixing Config Merge test
aaronpowell May 11, 2023
ea9ca6e
improving the test assert flow
aaronpowell May 11, 2023
b927fba
Removing Snapshooter from CLI tests
aaronpowell May 12, 2023
c0bb22d
Removed snapshooter from Service.Tests for VerifyTest
aaronpowell May 12, 2023
69eb552
Remove package version for Snapshooter
aaronpowell May 12, 2023
38530a0
Updating build pipeline to publish verify test output on failure
aaronpowell May 12, 2023
2df5524
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell May 12, 2023
c6a3401
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell May 15, 2023
0352c74
Bad merge on the cosmos config
aaronpowell May 15, 2023
bc49a91
Wasn't properly cloning existing permissions on update
aaronpowell May 15, 2023
79cb250
Fixing env var testing by creating a new mock application host
aaronpowell May 15, 2023
ba288c9
Fixing broken config for cosmos and some auth pipeline
aaronpowell May 15, 2023
da3a0e5
Handing that the model directive might not match entity in config
aaronpowell May 15, 2023
2b7df8d
Fixing verification test
aaronpowell May 15, 2023
81569c0
Using a params has for verify names
aaronpowell May 15, 2023
1a02421
Need to mock a method call
aaronpowell May 15, 2023
ecc96ce
Adding diffplex for better test debugging
aaronpowell May 15, 2023
095b7db
snapshot updated
aaronpowell May 15, 2023
9b118d6
Fixing test
aaronpowell May 15, 2023
27de7a9
Removing mstest from core service
aaronpowell May 15, 2023
857a378
Expanding the Create DB policy test coverage
aaronpowell May 15, 2023
b3dd45c
Serialization of json schema property was wrong
aaronpowell May 15, 2023
04da726
Improving the dynamic config loading via endpoint
aaronpowell May 16, 2023
9294aa2
Need a new line in the command script for config generation
aaronpowell May 16, 2023
14158c4
Config file regenerated
aaronpowell May 16, 2023
10bdaa8
Updated verified runtime config
aaronpowell May 16, 2023
b7ea176
Bad merge dropped DateTimeOffset support
aaronpowell May 16, 2023
286f4d5
Don't need to unpack sproc props from JSON anymore
aaronpowell May 16, 2023
522fc92
Ensuring right config is loaded and serialized properly
aaronpowell May 16, 2023
6d9f9d6
Fixing generated config
aaronpowell May 16, 2023
7e7a058
Better handling of lazy loading config files
aaronpowell May 16, 2023
bd9205b
Upsert not Update...
aaronpowell May 16, 2023
520c63a
Reverting change on how config file name is set
aaronpowell May 16, 2023
5de42bb
Fixing the DataRow attribute usage
aaronpowell May 16, 2023
7a429c0
Updating PostgreSQL and MySQL configs + snapshots
aaronpowell May 16, 2023
a480127
new hashing algo to meet SDL
aaronpowell May 16, 2023
a987ece
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell May 16, 2023
32cdec4
Removing the runtime env setting
aaronpowell May 16, 2023
e42c700
Moving snapshots into their own folder for easier PR reviews
aaronpowell May 17, 2023
7e96d51
Undoing launch file changes
aaronpowell May 17, 2023
75c0c03
Flag around UseHttpsRedirection
aaronpowell May 17, 2023
5ac9304
Apply suggestions from code review
aaronpowell May 18, 2023
d855aed
Update src/Service.GraphQLBuilder/GraphQLStoredProcedureBuilder.cs
aaronpowell May 18, 2023
9c0e207
Fixing a bad merge from code review and making Entities a ReadOnlyDic…
aaronpowell May 18, 2023
7988bad
Moving file up per review
aaronpowell May 18, 2023
8aa1f4b
Describing the logger
aaronpowell May 18, 2023
f3996f5
Adding doc comments for the RuntimeConfigLoader and Provider
aaronpowell May 18, 2023
f36a660
EntityType -> EntitySourceType for more obvious naming
aaronpowell May 18, 2023
cbea153
More doc comments describing types
aaronpowell May 18, 2023
22237bf
Removing the use of magic strings for data source options
aaronpowell May 19, 2023
8e48c71
Reverting a change where I dropped an enum and used a string
aaronpowell May 19, 2023
56f241f
Expanding the check to cover whitespace as well.
aaronpowell May 19, 2023
08293d6
Adding <inheritdoc /> for converter types
aaronpowell May 19, 2023
0173cbb
Fixing based on PR review feedback
aaronpowell May 22, 2023
7f0a6d7
More clarity on what files are being added
aaronpowell May 23, 2023
e3c1390
Merge branch 'aaronpowell/new-config-engine' of https://github.com/Az…
aaronpowell May 23, 2023
bba1ace
Fixing whitespace
aaronpowell May 25, 2023
964b6d8
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell May 25, 2023
556a381
Little tweak of if test
aaronpowell May 25, 2023
a4bb129
Updating Verify.MSTest to 20.1.0
aaronpowell May 25, 2023
34f4acf
Cleaned up verify test output
aaronpowell May 25, 2023
2e3c864
Fixing usage of default params
aaronpowell May 26, 2023
36c9b57
Moving the new types for the config to their own folder/namespace
aaronpowell May 26, 2023
055545e
formatting fix
aaronpowell May 26, 2023
ca7ce2b
Forgot to add this snapshot
aaronpowell May 26, 2023
6411614
More missing snapshots
aaronpowell May 26, 2023
19b4bb5
Update src/Config/DatabasePrimitives/DatabaseObject.cs
aaronpowell May 29, 2023
33cda15
Addressing the potentially incorrect naming of a param
aaronpowell May 29, 2023
fe8c79c
Moving away from Enum.Parse as it's not the most optimal in our codebase
aaronpowell May 29, 2023
e429969
adding a comment to explain why we reparse the dictionary
aaronpowell May 29, 2023
2a77d1e
Cleanup from code review
aaronpowell May 29, 2023
b7639d9
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell May 31, 2023
dd20173
Updating System.IO.Abstractions
aaronpowell May 31, 2023
cc6f202
Clearing up the message
aaronpowell Jun 1, 2023
89b69ce
Updated the method docs
aaronpowell Jun 1, 2023
56875c8
Incorporating review feedback
aaronpowell Jun 1, 2023
304a3b5
Incorporating review feedback
aaronpowell Jun 1, 2023
9dca707
Using null when it was expected
aaronpowell Jun 2, 2023
f306f3a
Fixing verify tests
aaronpowell Jun 2, 2023
8600e69
linting
aaronpowell Jun 2, 2023
2f66399
Fixing verify tests
aaronpowell Jun 2, 2023
85d4a85
Apply suggestions from code review
aaronpowell Jun 8, 2023
3e065b9
Removing the methods if REST is disabled for an entity
aaronpowell Jun 9, 2023
25407f6
Little clean up on these two converters
aaronpowell Jun 9, 2023
736af07
Fixing comment
aaronpowell Jun 9, 2023
4acb6cc
Bringing back comment explaining why Exlude isn't nullable
aaronpowell Jun 9, 2023
be78085
naming nullable fields
aaronpowell Jun 9, 2023
66b1526
Code optimisation
aaronpowell Jun 9, 2023
4b7d684
Pluralisation should only happen when creating the RuntimeEntities type
aaronpowell Jun 9, 2023
86fd0f8
Correct implementation of the JSON schema for REST path values
aaronpowell Jun 9, 2023
09df26f
Expanding doc comments
aaronpowell Jun 9, 2023
42df27f
Null handling
aaronpowell Jun 9, 2023
afeb272
Using string.Empty properly
aaronpowell Jun 9, 2023
7330fe5
Expanding abbreviation
aaronpowell Jun 9, 2023
da68eee
Changed from code review
aaronpowell Jun 9, 2023
5b9813f
Addressing feedback from PR review
aaronpowell Jun 13, 2023
e27eba9
Addressing feedback from PR review
aaronpowell Jun 13, 2023
59eca73
Removing unused enum member and code cleanup from review
aaronpowell Jun 13, 2023
d68af6d
Adding better logic to determine the right number value to use
aaronpowell Jun 13, 2023
e857f3e
Missed setting late config for new initialization endpoint
aaronpowell Jun 15, 2023
f63c50c
Removing unused doccomment
aaronpowell Jun 20, 2023
38afc1f
Adding a comment to explain why singular/plural might end up empty st…
aaronpowell Jun 20, 2023
fe51c01
Using the local variable
aaronpowell Jun 21, 2023
07ed782
Code review update
aaronpowell Jun 21, 2023
11c5a81
Code review update
aaronpowell Jun 21, 2023
78b76bc
Turns out that I should read the docs properly, step goes AFTER tests…
aaronpowell Jun 21, 2023
24f6e49
Error handling for when there's no database that can be determined fo…
aaronpowell Jun 21, 2023
b8fc53e
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell Jun 21, 2023
0419531
Checked for wrong auth type
aaronpowell Jun 21, 2023
2cbd53c
Addressing latest PR feedback
aaronpowell Jun 22, 2023
59456c5
Making the EntitySource.Type nullable (#1530)
aaronpowell Jun 22, 2023
e78ad79
Better usage of Verify and ensuring test cleanup
aaronpowell Jun 23, 2023
f44565d
Splitting the tests from data drive to separate tests
aaronpowell Jun 23, 2023
c333318
Avoiding reading to the end in case the process hadn't finished. Only…
aaronpowell Jun 23, 2023
11eb639
Removing cli config name precedence setting
aaronpowell Jun 23, 2023
a7ae343
Disabling a test temporarily, see comment on test for insights
aaronpowell Jun 23, 2023
d6b6dd4
Merge branch 'main' into aaronpowell/new-config-engine
aaronpowell Jun 23, 2023
f128532
code review update
aaronpowell Jun 27, 2023
3824eff
Merge branch 'aaronpowell/new-config-engine' of https://github.com/Az…
aaronpowell Jun 27, 2023
33a89a7
adds logic to retain existing gql operation, adds test
severussundar Jun 28, 2023
1862678
resolving merge conflicts
severussundar Jul 3, 2023
46eb19c
Merge branch 'main' into dev/shyamsundarj/bugfix-update-rest-methods
abhishekkumams Jul 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Cli.Tests/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,34 @@ public void TestUpdateEntity()
Assert.AreEqual("Company Name", entity.Mappings["name"]);
}

/// <summary>
/// Validates the updation of REST Methods for a stored procedure entity
/// </summary>
[TestMethod]
public Task TestUpdatingStoredProcedureWithRestMethods()
{
string[] initArgs = { "init", "-c", TEST_RUNTIME_CONFIG_FILE, "--database-type", "mssql",
"--host-mode", "Development", "--connection-string", "testconnectionstring", "--set-session-context", "true" };
Program.Execute(initArgs, _cliLogger!, _fileSystem!, _runtimeConfigLoader!);

Assert.IsTrue(_runtimeConfigLoader!.TryLoadConfig(TEST_RUNTIME_CONFIG_FILE, out RuntimeConfig? runtimeConfig));
Assert.IsNotNull(runtimeConfig);
Assert.AreEqual(0, runtimeConfig.Entities.Count()); // No entities

string[] addArgs = { "add", "MyEntity", "-c", TEST_RUNTIME_CONFIG_FILE, "--source", "s001.book", "--permissions", "anonymous:execute", "--source.type", "stored-procedure", "--source.params", "param1:123,param2:hello,param3:true", "--rest.methods", "post,put,patch", "--graphql.operation", "query" };
Program.Execute(addArgs, _cliLogger!, _fileSystem!, _runtimeConfigLoader!);

Assert.IsTrue(_runtimeConfigLoader!.TryLoadConfig(TEST_RUNTIME_CONFIG_FILE, out RuntimeConfig? updatedRuntimeConfig));
Assert.AreNotSame(runtimeConfig, updatedRuntimeConfig);

string[] updateArgs = { "update", "MyEntity", "-c", TEST_RUNTIME_CONFIG_FILE, "--rest.methods", "get" };
Program.Execute(updateArgs, _cliLogger!, _fileSystem!, _runtimeConfigLoader!);

Assert.IsTrue(_runtimeConfigLoader!.TryLoadConfig(TEST_RUNTIME_CONFIG_FILE, out RuntimeConfig? updatedRuntimeConfig2));
Assert.AreNotSame(updatedRuntimeConfig, updatedRuntimeConfig2);
return Verify(updatedRuntimeConfig2);
}

/// <summary>
/// Test to validate that the engine starts successfully when --verbose and --LogLevel
/// options are used with the start command
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
DataSource: {
DatabaseType: MSSQL,
Options: {
set-session-context: {
ValueKind: True
}
}
},
Runtime: {
Rest: {
Enabled: true,
Path: /api
},
GraphQL: {
Enabled: true,
Path: /graphql,
AllowIntrospection: true
},
Host: {
Cors: {
AllowCredentials: false
},
Authentication: {
Provider: StaticWebApps,
Jwt: {}
}
}
},
Entities: [
{
MyEntity: {
Source: {
Object: s001.book,
Type: stored-procedure,
Parameters: {
param1: 123,
param2: hello,
param3: true
}
},
GraphQL: {
Singular: MyEntity,
Plural: MyEntities,
Enabled: true,
Operation: Query
},
Rest: {
Methods: [
Get
],
Enabled: true
},
Permissions: [
{
Role: anonymous,
Actions: [
{
Action: Execute,
Policy: {}
}
]
}
]
}
}
]
}
8 changes: 7 additions & 1 deletion src/Cli/ConfigGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ private static EntityGraphQLOptions ConstructUpdatedGraphQLDetails(Entity entity
{
//Updated GraphQL Type
EntityGraphQLOptions graphQLType = (options.GraphQLType is not null) ? ConstructGraphQLTypeDetails(options.GraphQLType, null) : entity.GraphQL;
GraphQLOperation? graphQLOperation = null;
GraphQLOperation? graphQLOperation;

if (!IsStoredProcedureConvertedToOtherTypes(entity, options)
&& (IsStoredProcedure(entity) || IsStoredProcedure(options)))
Expand All @@ -1111,6 +1111,12 @@ private static EntityGraphQLOptions ConstructUpdatedGraphQLDetails(Entity entity
graphQLOperation = null;
}
}
else
{
// When the GraphQL operation for a SP entity has not been specified in the update command,
// assign the existing GraphQL operation.
graphQLOperation = entity.GraphQL.Operation;
}
}
else
{
Expand Down