Skip to content

Commit

Permalink
Defaults to NTLM authentication
Browse files Browse the repository at this point in the history
Preserves backward compatibility with 0.1.0

Close #45
  • Loading branch information
tagliala committed Jun 4, 2024
1 parent 2176a58 commit b3dde01
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ And then execute:

You can instantiate a number of SharePoint clients in your application:

#### Token authentication
#### NTLM authentication (default)

```rb
client = Sharepoint::Client.new({
authentication: "token",
client_id: "client_id",
client_secret: "client_secret",
tenant_id: "tenant_id",
cert_name: "cert_name",
auth_scope: "auth_scope",
authentication: "ntlm", # default, can be omitted
username: "username",
password: "password",
uri: "http://sharepoint_url"
})
```

#### NTLM authentication
#### Token authentication

```rb
client = Sharepoint::Client.new({
authentication: "ntlm",
username: "username",
password: "password",
authentication: "token",
client_id: "client_id",
client_secret: "client_secret",
tenant_id: "tenant_id",
cert_name: "cert_name",
auth_scope: "auth_scope",
uri: "http://sharepoint_url"
})
```
Expand Down
1 change: 1 addition & 0 deletions lib/sharepoint/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def bearer_auth
# - `:auth_scope` self-explanatory
# @return [Sharepoint::Client] client object
def initialize(config = {})
config[:authentication] = 'ntlm' unless config.key?(:authentication)
@config = OpenStruct.new(config)
@token = Token.new(@config)
validate_config!
Expand Down
2 changes: 1 addition & 1 deletion lib/sharepoint/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Sharepoint
module Version
MAJOR = 0
MINOR = 2
PATCH = 0
PATCH = 1
BUILD = nil

VERSION = [MAJOR, MINOR, PATCH, BUILD].compact.join('.').freeze
Expand Down
16 changes: 16 additions & 0 deletions spec/lib/sharepoint/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@
end
end

context 'when authentication is not specified' do
subject(:client) { described_class.new(legacy_config) }

let(:legacy_config) do
{ username: 'test', password: 'test', uri: 'http://sharepoint.example.com' }
end

it 'defaults to ntlm' do
expect do
client
end.not_to raise_error

expect(client.config.authentication).to eq 'ntlm'
end
end

context 'with ethon easy options' do
context 'with success' do
let(:config_ethon) { config.merge({ ethon_easy_options: ssl_verifypeer }) }
Expand Down

0 comments on commit b3dde01

Please sign in to comment.