Skip to content

Commit

Permalink
Fixes on permission validator
Browse files Browse the repository at this point in the history
  • Loading branch information
FherStk committed Dec 16, 2019
1 parent 81a201e commit 50cca6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static void Main(string[] args)
{
Utils.BreakLine();
Utils.Write("Automated Assignment Validator: ", ConsoleColor.Yellow);
Utils.WriteLine("v1.2.4.3");
Utils.WriteLine("v1.2.5.0");
Utils.Write(String.Format("Copyright © {0}: ", DateTime.Now.Year), ConsoleColor.Yellow);
Utils.WriteLine("Fernando Porrino Serrano. Under the AGPL license (https://github.com/FherStk/ASIX-DAM-M04-WebAssignmentValidator/blob/master/LICENSE)");

Expand Down
9 changes: 7 additions & 2 deletions src/PermissionsValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void ValidateAssignment(string server, string database, bool oldVe

List<string> currentErrors;
List<string> globalErrors;
ClearResults();
ClearResults(conn);

//question 1
if(oldVersion) success+=1; //Yes... I know... At least I removed it on the new version...
Expand Down Expand Up @@ -155,9 +155,14 @@ public static void ValidateAssignment(string server, string database, bool oldVe
Utils.PrintScore(success, errors);
}
}
private static void ClearResults(){
private static void ClearResults(NpgsqlConnection conn){
success = 0;
errors = 0;

//TODO: create the roles (rrhhadmin, prodadmin, dbadmin) and the user (it) if them not exists; also set the default permissions
using (NpgsqlCommand cmd = new NpgsqlCommand("REVOKE rrhhadmin FROM dbadmin; REVOKE prodadmin FROM dbadmin;", conn)){
cmd.ExecuteNonQuery();
}
}
private static void ProcessResults(List<string> list, int score = 1){
if(list.Count == 0) success+=score;
Expand Down

0 comments on commit 50cca6a

Please sign in to comment.