Skip to content
This repository was archived by the owner on Jun 4, 2023. It is now read-only.

Commit 9480778

Browse files
authored
Fix remove record from cloudflare (#6)
* Fix remove dns record from cloudflare * allow push images from PR * Update selenium * Use normalized dns name * uncomment docker push rule Co-authored-by: Клабуков Эрик Константинович <klabukov@skbkontur.ru>
1 parent 833c944 commit 9480778

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN dotnet publish ./DotNetCertBot.Host/DotNetCertBot.Host.csproj -c Release --s
66
dotnet nuget locals http-cache --clear;\
77
dotnet nuget locals temp --clear
88

9-
FROM selenium/standalone-chrome:96.0.4664.110 as certbot
9+
FROM selenium/standalone-chrome:97.0 as certbot
1010
COPY --from=build /app /certbot
1111
WORKDIR /certbot
1212
USER root

DotNetCertBot.CloudFlareUserApi/CloudFlareServiceSelenium.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public CloudFlareServiceSelenium(IConfiguration configuration, ILogger<CloudFlar
4141
{"userAgent", RandomUserAgent.Generate()}
4242
});
4343
_driver.Navigate().GoToUrl(CloudFlareLoginUrl);
44-
_waiter = new WebDriverWait(_driver, TimeSpan.FromSeconds(25));
44+
_waiter = new WebDriverWait(_driver, TimeSpan.FromSeconds(40));
4545
}
4646

4747
public async Task<bool> CheckAuth()
@@ -82,11 +82,13 @@ public Task ClearChallenge(string zoneName, string name)
8282
{
8383
return Task.Run(async () =>
8484
{
85-
var normalizedName = NormalizeDnsName(name, zoneName);
86-
_logger.LogInformation("Remove {txtName} form zone {zoneName}", normalizedName, zoneName);
87-
var dnsRecord = _waiter.Until(d =>
88-
d.FindElement(By.XPath($"//div[contains(text(),'{normalizedName}')]")));
89-
await MouseClick(dnsRecord);
85+
var normalizedDnsName = NormalizeDnsName(name, zoneName);
86+
_logger.LogInformation("Remove {txtName} from zone {zoneName}", normalizedDnsName, zoneName);
87+
var dnsRecordCell = _waiter.Until(d =>
88+
d.FindElement(By.XPath($"//div[contains(text(),'{normalizedDnsName}')]")));
89+
var dnsRecordRow = dnsRecordCell.GetParent().GetParent();
90+
var editButton = dnsRecordRow.FindElements(By.TagName("button")).Last();
91+
await MouseClick(editButton);
9092
var deleteButton = _waiter.Until(d => d.FindElement(By.XPath("//button[contains(text(),'Delete')]")));
9193
await MouseClick(deleteButton);
9294
var iSureDeleteButton =

DotNetCertBot.CloudFlareUserApi/DotNetCertBot.CloudFlareUserApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.13" />
1010
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.13" />
1111
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
12-
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="96.0.4664.4500" />
12+
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="97.0.4692.7100" />
1313
<PackageReference Include="Skidbladnir.Modules" Version="1.3.3-unstalable.0.2" />
1414
</ItemGroup>
1515

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using OpenQA.Selenium;
2+
3+
namespace DotNetCertBot.CloudFlareUserApi
4+
{
5+
internal static class SeleniumExtensions
6+
{
7+
public static IWebElement GetParent(this IWebElement node)
8+
{
9+
return node.FindElement(By.XPath(".."));
10+
}
11+
}
12+
}

DotNetCertBot.Host/DotNetCertBot.Host.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="3.1.13" />
1111
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.13" />
1212
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.13" />
13-
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="96.0.4664.4500" />
13+
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="97.0.4692.7100" />
1414
<PackageReference Include="Skidbladnir.Modules" Version="1.3.3-unstalable.0.2" />
1515
</ItemGroup>
1616

0 commit comments

Comments
 (0)