|
@@ -0,0 +1,34 @@
|
|
1
|
+require "dotenv/load"
|
|
2
|
+require "slack_mattermost_emoji/mattermost_client"
|
|
3
|
+
|
|
4
|
+RSpec.describe SlackMattermostEmoji::MattermostClient do
|
|
5
|
+ it 'should raise if credentials are missing' do
|
|
6
|
+ expect do
|
|
7
|
+ SlackMattermostEmoji::MattermostClient.new(
|
|
8
|
+ username: '',
|
|
9
|
+ password: '',
|
|
10
|
+ domain: '',
|
|
11
|
+ )
|
|
12
|
+ end.to raise_error('Mattermost username, password, and domain are all required')
|
|
13
|
+ end
|
|
14
|
+
|
|
15
|
+ it 'should be able to log in to mattermost using the provided credentials' do
|
|
16
|
+ client = SlackMattermostEmoji::MattermostClient.new(
|
|
17
|
+ username: ENV['MATTERMOST_USERNAME'],
|
|
18
|
+ password: ENV['MATTERMOST_PASSWORD'],
|
|
19
|
+ domain: ENV['MATTERMOST_DOMAIN'],
|
|
20
|
+ )
|
|
21
|
+ client.authenticate
|
|
22
|
+
|
|
23
|
+ expect(client.authenticated?).to be true
|
|
24
|
+ end
|
|
25
|
+
|
|
26
|
+ it 'should handle a bad credentials error' do
|
|
27
|
+ client = SlackMattermostEmoji::MattermostClient.new(
|
|
28
|
+ username: ENV['MATTERMOST_USERNAME'],
|
|
29
|
+ password: 'wrongpassword',
|
|
30
|
+ domain: ENV['MATTERMOST_DOMAIN'],
|
|
31
|
+ )
|
|
32
|
+ expect { client.authenticate }.to raise_error('Invalid Mattermost credentials')
|
|
33
|
+ end
|
|
34
|
+end
|