Help language development. Donate to The Perl Foundation

Auth::SASL cpan:HANENKAMP last updated on 2020-02-06

use v6;

use Auth::SASL;
use Test;

my $sasl =;

multi my-callback('pass', *%_) {
    pass('pass callback works');

multi my-callback('authname', :$service, :$host) {
    if $service eq 'ldap' && $host eq 'localhost' {
        pass('authname with service/host check works');
    else {
        flunk('authname with service/host check fails');

    data => %(
        user => 'zostay',
    callback => &my-callback,

ok $sasl, 'constructed';
isa-ok $sasl, Auth::SASL;

my @mechs = $sasl.attempt-mechanisms('PLAIN', :service<ldap>, :host<localhost>);
is @mechs.elems, 1, 'got one mechanism';

is @mechs[0].mechanism, 'PLAIN', 'sasl mech is PLAIN';
is @mechs[0].is-complete, False, 'mechanism has work to do';
is @mechs[0].step, "cheese\0zostay\0oofoof", 'step does the thing';
is @mechs[0].is-complete, True, 'mechanism is finished';