Skip to content

Commit

Permalink
style(sdk core tests): updated sdk core tests code style to match the…
Browse files Browse the repository at this point in the history
… guidelines of stylecop linter
  • Loading branch information
kevinkowa committed Jul 30, 2020
1 parent c345f67 commit 9cce7c7
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 211 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ dotnet_diagnostic.SA1622.severity = none
# SA1118: Parameter should not span multiple lines
dotnet_diagnostic.SA1118.severity = none

dotnet_diagnostic.SA0001.severity = none
dotnet_diagnostic.SA0001.severity = none

50 changes: 32 additions & 18 deletions test/IBM.Cloud.SDK.Core.Tests/BasicAuthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -15,13 +15,13 @@
*
*/

using System;
using System.Collections.Generic;
using System.Text;
using IBM.Cloud.SDK.Core.Authentication;
using IBM.Cloud.SDK.Core.Authentication.BasicAuth;
using IBM.Cloud.SDK.Core.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;

namespace IBM.Cloud.SDK.Core.Tests.Authentication.BasicAuth
{
Expand Down Expand Up @@ -72,85 +72,99 @@ public void TestAuthenticate()
Assert.IsTrue(client.BaseClient.DefaultRequestHeaders.Authorization.ToString() == "Basic " + auth64);
}

[TestMethod, ExpectedException(typeof(ArgumentNullException))]
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void TestNullUsername()
{
BasicAuthenticator authenticator = new BasicAuthenticator(null, "password");
}

[TestMethod, ExpectedException(typeof(ArgumentNullException))]
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void TestNullPassword()
{
BasicAuthenticator authenticator = new BasicAuthenticator("username", null);
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadUsernameBracketBeginning()
{
BasicAuthenticator authenticator = new BasicAuthenticator("{username", "password");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadPasswordBracketBeginning()
{
BasicAuthenticator authenticator = new BasicAuthenticator("username", "{pasword");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadUsernameBracketEnd()
{
BasicAuthenticator authenticator = new BasicAuthenticator("username}", "password");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadPasswordBracketEnd()
{
BasicAuthenticator authenticator = new BasicAuthenticator("username", "pasword}");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadUsernameBeginningBracketEnd()
{
BasicAuthenticator authenticator = new BasicAuthenticator("{username}", "password");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadPasswordBeginningBracketEnd()
{
BasicAuthenticator authenticator = new BasicAuthenticator("username", "{pasword}");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadUsernameQuoteBeginning()
{
BasicAuthenticator authenticator = new BasicAuthenticator("\"username", "password");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadPasswordQuoteBeginning()
{
BasicAuthenticator authenticator = new BasicAuthenticator("username", "\"pasword");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadUsernameQuoteEnd()
{
BasicAuthenticator authenticator = new BasicAuthenticator("username\"", "password");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadPasswordQuoteEnd()
{
BasicAuthenticator authenticator = new BasicAuthenticator("username", "pasword\"");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadUsernameBeginningQuoteEnd()
{
BasicAuthenticator authenticator = new BasicAuthenticator("\"username\"", "password");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadPasswordBeginningQuoteEnd()
{
BasicAuthenticator authenticator = new BasicAuthenticator("username", "\"pasword\"");
Expand Down
27 changes: 17 additions & 10 deletions test/IBM.Cloud.SDK.Core.Tests/BearerTokenAuthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -15,12 +15,12 @@
*
*/

using System;
using System.Collections.Generic;
using IBM.Cloud.SDK.Core.Authentication;
using IBM.Cloud.SDK.Core.Authentication.Bearer;
using IBM.Cloud.SDK.Core.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace IBM.Cloud.SDK.Core.Tests.Authentication.BearerTokenAuth
{
Expand Down Expand Up @@ -81,43 +81,50 @@ public void TestAuthenticate()
Assert.IsTrue(client.BaseClient.DefaultRequestHeaders.Authorization.ToString() == "Bearer " + bearerToken);
}

[TestMethod, ExpectedException(typeof(ArgumentNullException))]
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void TestNullBearerToken()
{
BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator(bearerToken: null);
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadBearerTokenBracketBeginning()
{
BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator("{username");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadBearerTokenBracketEnd()
{
BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator("username}");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadBearerTokenBeginningBracketEnd()
{
BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator("{username}");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadBearerTokenQuoteBeginning()
{
BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator("\"username");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadBearerTokenQuoteEnd()
{
BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator("username\"");
}

[TestMethod, ExpectedException(typeof(ArgumentException))]
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void TestBadBearerTokenBeginningQuoteEnd()
{
BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator("\"username\"");
Expand Down

0 comments on commit 9cce7c7

Please sign in to comment.