Skip to content

Commit

Permalink
Validate environment URL in OpenAppCommand
Browse files Browse the repository at this point in the history
Added checks to ensure the environment URL is neither empty nor incorrectly formatted in OpenAppCommand.cs. Also, included JSON ignore annotation for SimpleloginUri property in ConfigurationOptions.cs to prevent serialization issues.
  • Loading branch information
Kirill Krylo committed Sep 5, 2024
1 parent 402d88a commit d7e6da4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 0 additions & 4 deletions clio.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@ Global
{718FE94B-0CB7-4977-B2D7-E661C8E57555}.Release|Any CPU.ActiveCfg = Release|Any CPU
{718FE94B-0CB7-4977-B2D7-E661C8E57555}.Release|Any CPU.Build.0 = Release|Any CPU
{E24226F9-C177-458F-AF34-9338E2699983}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E24226F9-C177-458F-AF34-9338E2699983}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E24226F9-C177-458F-AF34-9338E2699983}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E24226F9-C177-458F-AF34-9338E2699983}.Release|Any CPU.Build.0 = Release|Any CPU
{9DDD1340-FA52-4402-BF10-11C46BA9F7A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DDD1340-FA52-4402-BF10-11C46BA9F7A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DDD1340-FA52-4402-BF10-11C46BA9F7A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DDD1340-FA52-4402-BF10-11C46BA9F7A0}.Release|Any CPU.Build.0 = Release|Any CPU
{DD970BB9-CAD2-4C63-9017-91C6859B39EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD970BB9-CAD2-4C63-9017-91C6859B39EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD970BB9-CAD2-4C63-9017-91C6859B39EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
13 changes: 13 additions & 0 deletions clio/Command/OpenAppCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ public override int Execute(OpenAppOptions options) {
try {
var settings = new SettingsRepository();
var env = settings.GetEnvironment(options);

if(string.IsNullOrEmpty(env.Uri)) {
Logger.WriteError($"Environment:{options.Environment ?? ""} has empty url. Use 'clio reg-web-app' command to configure it.");
return 1;
}

if(!Uri.TryCreate(env.Uri, UriKind.Absolute, out Uri _)) {
Logger.WriteError($"Environment:{options.Environment ?? ""} has incorrect url format. Actual Url: '{env.Uri}' " +
$"Use \r\n\r\n\tclio cfg -e {options.Environment} -u <correct-url-here>\r\n\r\n command to configure it.");
return 1;
}


WebBrowser.OpenUrl(env.SimpleloginUri);
return 0;
} catch (Exception e) {
Expand Down
4 changes: 4 additions & 0 deletions clio/Environment/ConfigurationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ public string AuthAppUri {
}

[YamlIgnore]
[Newtonsoft.Json.JsonIgnore]
public string SimpleloginUri {
get {
if(Uri == null) {
return "";
}
var cleanUri = Uri;
if (!string.IsNullOrEmpty(cleanUri)) {
var domain = ".creatio.com";
Expand Down

0 comments on commit d7e6da4

Please sign in to comment.