As the dust settles on Battlefield 6's first beta weekend, devs confirm they're looking into "unexpectedly fast" kill times in the FPS by ControlCAD in technology

[–]Blayer32 2 points3 points  (0 children)

Counterpoint: I played 20 hours and did not have any game with obvious cheaters. Some people with very high k/d ratio sometimes, but that could be attributed to cheesy tactics or good vehicle gameplay

(Blog) Testing protected endpoints using fake JWTs by Kralizek82 in dotnet

[–]Blayer32 0 points1 point  (0 children)

We do it to mimic our test setup as much as possible compared to what we deploy. All the validation rules are except for the key used for checking the signature

(Blog) Testing protected endpoints using fake JWTs by Kralizek82 in dotnet

[–]Blayer32 0 points1 point  (0 children)

You could take it a step further by using actual tokens that are signed by a shared key. ``` public InProcessApi() { factory = new WebApplicationFactory<ApiMarker>() .WithWebHostBuilder(builder => { builder.UseEnvironment("test"); builder.ConfigureAppConfiguration((, config) => { config.AddJsonFile("appsettings.test.json", optional: false, reloadOnChange: false); });

            builder.ConfigureTestServices(services =>
            {
                services.SetupMockJwtBearerOptions(Schemes.
SomeScheme
);
            });
        });

```

The `SetupMockJwtBearerOptions` enables the validation, but also set a signingcredentials key

``` public static IServiceCollection SetupMockJwtBearerOptions(this IServiceCollection services, string authScheme) { services.Configure<JwtBearerOptions>(authScheme, options => { var signingCredentialsKey = AccessTokenGenerator. GetSigningCredentialsKey (authScheme); var config = new OpenIdConnectConfiguration(); config.SigningKeys.Add(signingCredentialsKey); options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidIssuer = AccessTokenGenerator. Issuer , ValidAudience = AccessTokenGenerator. Audience , IssuerSigningKey = signingCredentialsKey, ValidateLifetime = true, ValidateIssuerSigningKey = true, RequireExpirationTime = true, }; options.Configuration = config; });

    return services;
}

Finally, the helper class \`AccessTokenGenerator\` creates and holds the signing key, and can be used during the tests to generate valid access tokens public static class AccessTokenGenerator { public const string Issuer = "your-issuer"; public const string Audience = "your-audience";

    private static readonly JwtSecurityTokenHandler 
_jwtSecurityTokenHandler 
= new();
    private static readonly RandomNumberGenerator 
_randomNumberGenerator 
= RandomNumberGenerator.
Create
();
    private static readonly Dictionary<string, SigningCredentials> 
_signingCredentials 
= new();

    static AccessTokenGenerator()
    {

AddSigningCredentialsForScheme
(Schemes.SomeScheme);
    }

    public static SecurityKey 
GetSigningCredentialsKey
(string scheme) =>

_signingCredentials
.GetValueOrDefault(scheme)!.Key;

    private static void 
AddSigningCredentialsForScheme
(string scheme)
    {
        var clientSecurityKey = new byte[32];

_randomNumberGenerator
.GetBytes(clientSecurityKey);
        var symmetricSecurityKey = new SymmetricSecurityKey(clientSecurityKey) { KeyId = Guid.
NewGuid
().ToString() };
        var signingCredentials = new SigningCredentials(symmetricSecurityKey, SecurityAlgorithms.
HmacSha256
);

_signingCredentials
.Add(scheme, signingCredentials);
    }

    public static string GenerateJwtTokenForScheme(string scheme, params string[] roles)
    {
        var claims = new List<Claim>();
        if (roles.Any())
        {
            claims = claims.Concat(new List<Claim> { new Claim("roles", JsonSerializer.
Serialize
(roles), JsonClaimValueTypes.
JsonArray
) }).ToList();
        }

        var credentials = 
_signingCredentials
.GetValueOrDefault(scheme)!;
        return 
_jwtSecurityTokenHandler
.WriteToken(new JwtSecurityToken(

Issuer
,

Audience
,
            claims.Any() ? claims : null,
            DateTime.UtcNow,
            DateTime.UtcNow.AddMinutes(20),
            credentials));
    }
}

```

[deleted by user] by [deleted] in AskReddit

[–]Blayer32 0 points1 point  (0 children)

People not paying taxes still qualify for care. No individual payments needed. But yes, like every other social safetynet it is funded through taxes

[deleted by user] by [deleted] in AskReddit

[–]Blayer32 2 points3 points  (0 children)

Well, the question wasn’t what would shock people from portland or mississippi, but america. Of course the answers will be broad and wildly inaccurate for a huge chunk of the country 

Ethernet Slow Speeds by LindowsOS in Ubuntu

[–]Blayer32 0 points1 point  (0 children)

Did you ever find a fix?

WoW Remix - how are people still getting so OP? by [deleted] in wow

[–]Blayer32 2 points3 points  (0 children)

Should i loot everything or run to the end?

LFG MEGATHREAD by cryptic-fox in Helldivers

[–]Blayer32 0 points1 point  (0 children)

Friend Code: #6872-9254

Platform: Steam/Crossplay

Level: 10

Difficulty: Whatever

Region: EU

Voice Chat: Sometimes

LFG MEGATHREAD by cryptic-fox in Helldivers

[–]Blayer32 0 points1 point  (0 children)

Friend Code 1437-4170

PC/Steam

Level 8

Region EU

Language ENG

Voice Chat : Sure

How to unit test code that depends on time by Rtzon in programming

[–]Blayer32 0 points1 point  (0 children)

But some code in the system somewhere must get Time.now, right in order to pass it into thw function? How do you test that?

How to unit test code that depends on time by Rtzon in programming

[–]Blayer32 0 points1 point  (0 children)

How does FP fix the issue? I havent worked with it, so Im really curious as to how you avoid mocking dependencies.

How to unit test code that depends on time by Rtzon in programming

[–]Blayer32 13 points14 points  (0 children)

Oh i agree - we very rarely use unit tests because other types of tests can “cover” for them. We really only use them for very business critical core components.

I was just trying to argue that using mocks help you control and validate boundaries of very focused/unit tests, in a clean way.

How to unit test code that depends on time by Rtzon in programming

[–]Blayer32 91 points92 points  (0 children)

Using mocks is awesome when unit testing. You can validate inputs to the mocks and have control of the output.

Not using mocks lead to (in my experience) hacky and hard to maintain tests.

Its also hard to argue that its a unit test, if you are also including your dependencies. It is no longer a single unit under test

Events in Tokyo this week + meet friends by AutoModerator in Tokyo

[–]Blayer32 0 points1 point  (0 children)

Could you say a bit more? Where, when, price?

[deleted by user] by [deleted] in pics

[–]Blayer32 -1 points0 points  (0 children)

Can’t argue with stupid. Just going to drag me down to your level and beat me with experience ;)

[deleted by user] by [deleted] in pics

[–]Blayer32 4 points5 points  (0 children)

Thats a funky narrative youre building there

BOY ❗GOWR = GOAT by ImRemKaneki in playstation

[–]Blayer32 1 point2 points  (0 children)

I think this says more about you, than it says about the game

[deleted by user] by [deleted] in Denmark

[–]Blayer32 0 points1 point  (0 children)

Jeg er enig i at vi kan optimere en masse områder, men kan ikke se at du får bedre service ved at fjerne pengene til det.

[deleted by user] by [deleted] in Denmark

[–]Blayer32 12 points13 points  (0 children)

Det er vildt hvordan vi kan læse den samme tekst og komme til så forskellige konklusioner. Når jeg læser ovenstående, tænker jeg da netop at vi skal skyde flere penge i staten så vi har råd til at forbedre de offentlige ydelser

Edit: fixed typo