@@ -9,35 +9,28 @@ public class AuthTests
9
9
[ SetUp ]
10
10
public void Setup ( )
11
11
{
12
- File . WriteAllText ( ".openai" , "OPENAI_KEY=pk-test12" + Environment . NewLine + "OPENAI_SECRET_KEY: sk-test34" ) ;
12
+ File . WriteAllText ( ".openai" , "OPENAI_KEY=pk-test12" ) ;
13
13
Environment . SetEnvironmentVariable ( "OPENAI_KEY" , "pk-test-env" ) ;
14
- Environment . SetEnvironmentVariable ( "OPENAI_SECRET_KEY" , "sk-test-env" ) ;
14
+ // Environment.SetEnvironmentVariable("OPENAI_SECRET_KEY", "sk-test-env");
15
15
}
16
16
17
17
[ Test ]
18
18
public void GetAuthFromEnv ( )
19
19
{
20
20
var auth = OpenAI_API . APIAuthentication . LoadFromEnv ( ) ;
21
21
Assert . IsNotNull ( auth ) ;
22
- Assert . IsNotNull ( auth . APIKey ) ;
23
- Assert . IsNotEmpty ( auth . APIKey ) ;
24
- Assert . AreEqual ( "pk-test-env" , auth . APIKey ) ;
25
-
26
- Assert . IsNotNull ( auth . Secretkey ) ;
27
- Assert . IsNotEmpty ( auth . Secretkey ) ;
28
- Assert . AreEqual ( "sk-test-env" , auth . Secretkey ) ;
29
-
22
+ Assert . IsNotNull ( auth . ApiKey ) ;
23
+ Assert . IsNotEmpty ( auth . ApiKey ) ;
24
+ Assert . AreEqual ( "pk-test-env" , auth . ApiKey ) ;
30
25
}
31
26
32
27
[ Test ]
33
28
public void GetAuthFromFile ( )
34
29
{
35
30
var auth = OpenAI_API . APIAuthentication . LoadFromPath ( ) ;
36
31
Assert . IsNotNull ( auth ) ;
37
- Assert . IsNotNull ( auth . APIKey ) ;
38
- Assert . AreEqual ( "pk-test12" , auth . APIKey ) ;
39
- Assert . IsNotNull ( auth . Secretkey ) ;
40
- Assert . AreEqual ( "sk-test34" , auth . Secretkey ) ;
32
+ Assert . IsNotNull ( auth . ApiKey ) ;
33
+ Assert . AreEqual ( "pk-test12" , auth . ApiKey ) ;
41
34
}
42
35
43
36
@@ -55,10 +48,8 @@ public void GetDefault()
55
48
var auth = OpenAI_API . APIAuthentication . Default ;
56
49
var envAuth = OpenAI_API . APIAuthentication . LoadFromEnv ( ) ;
57
50
Assert . IsNotNull ( auth ) ;
58
- Assert . IsNotNull ( auth . APIKey ) ;
59
- Assert . AreEqual ( envAuth . APIKey , auth . APIKey ) ;
60
- Assert . IsNotNull ( auth . Secretkey ) ;
61
- Assert . AreEqual ( envAuth . Secretkey , auth . Secretkey ) ;
51
+ Assert . IsNotNull ( auth . ApiKey ) ;
52
+ Assert . AreEqual ( envAuth . ApiKey , auth . ApiKey ) ;
62
53
}
63
54
64
55
@@ -67,57 +58,42 @@ public void GetDefault()
67
58
public void testHelper ( )
68
59
{
69
60
OpenAI_API . APIAuthentication defaultAuth = OpenAI_API . APIAuthentication . Default ;
70
- OpenAI_API . APIAuthentication manualAuth = new OpenAI_API . APIAuthentication ( "pk-testAA" , "sk-testBB" ) ;
61
+ OpenAI_API . APIAuthentication manualAuth = new OpenAI_API . APIAuthentication ( "pk-testAA" ) ;
71
62
OpenAI_API . OpenAIAPI api = new OpenAI_API . OpenAIAPI ( ) ;
72
63
OpenAI_API . APIAuthentication shouldBeDefaultAuth = api . Auth ;
73
64
Assert . IsNotNull ( shouldBeDefaultAuth ) ;
74
- Assert . IsNotNull ( shouldBeDefaultAuth . APIKey ) ;
75
- Assert . AreEqual ( defaultAuth . APIKey , shouldBeDefaultAuth . APIKey ) ;
76
- Assert . IsNotNull ( shouldBeDefaultAuth . Secretkey ) ;
77
- Assert . AreEqual ( defaultAuth . Secretkey , shouldBeDefaultAuth . Secretkey ) ;
65
+ Assert . IsNotNull ( shouldBeDefaultAuth . ApiKey ) ;
66
+ Assert . AreEqual ( defaultAuth . ApiKey , shouldBeDefaultAuth . ApiKey ) ;
78
67
79
- OpenAI_API . APIAuthentication . Default = new OpenAI_API . APIAuthentication ( "pk-testAA" , "sk-testBB" ) ;
68
+ OpenAI_API . APIAuthentication . Default = new OpenAI_API . APIAuthentication ( "pk-testAA" ) ;
80
69
api = new OpenAI_API . OpenAIAPI ( ) ;
81
70
OpenAI_API . APIAuthentication shouldBeManualAuth = api . Auth ;
82
71
Assert . IsNotNull ( shouldBeManualAuth ) ;
83
- Assert . IsNotNull ( shouldBeManualAuth . APIKey ) ;
84
- Assert . AreEqual ( manualAuth . APIKey , shouldBeManualAuth . APIKey ) ;
85
- Assert . IsNotNull ( shouldBeManualAuth . Secretkey ) ;
86
- Assert . AreEqual ( manualAuth . Secretkey , shouldBeManualAuth . Secretkey ) ;
72
+ Assert . IsNotNull ( shouldBeManualAuth . ApiKey ) ;
73
+ Assert . AreEqual ( manualAuth . ApiKey , shouldBeManualAuth . ApiKey ) ;
87
74
}
88
75
89
76
[ Test ]
90
77
public void GetKey ( )
91
78
{
92
- var auth = new OpenAI_API . APIAuthentication ( "pk-testAA" , "sk-testBB" ) ;
93
- Assert . IsNotNull ( auth . GetKey ( ) ) ;
94
- Assert . AreEqual ( "sk-testBB" , auth . GetKey ( ) ) ;
95
-
96
- auth = new OpenAI_API . APIAuthentication ( "pk-testAA" , null ) ;
97
- Assert . IsNotNull ( auth . GetKey ( ) ) ;
98
- Assert . AreEqual ( "pk-testAA" , auth . GetKey ( ) ) ;
79
+ var auth = new OpenAI_API . APIAuthentication ( "pk-testAA" ) ;
80
+ Assert . IsNotNull ( auth . ApiKey ) ;
81
+ Assert . AreEqual ( "pk-testAA" , auth . ApiKey ) ;
99
82
}
100
83
101
84
[ Test ]
102
85
public void ParseKey ( )
103
86
{
104
87
var auth = new OpenAI_API . APIAuthentication ( "pk-testAA" ) ;
105
- Assert . IsNotNull ( auth . APIKey ) ;
106
- Assert . IsNull ( auth . Secretkey ) ;
107
- Assert . AreEqual ( "pk-testAA" , auth . APIKey ) ;
88
+ Assert . IsNotNull ( auth . ApiKey ) ;
89
+ Assert . AreEqual ( "pk-testAA" , auth . ApiKey ) ;
108
90
auth = "pk-testCC" ;
109
- Assert . IsNotNull ( auth . APIKey ) ;
110
- Assert . IsNull ( auth . Secretkey ) ;
111
- Assert . AreEqual ( "pk-testCC" , auth . APIKey ) ;
91
+ Assert . IsNotNull ( auth . ApiKey ) ;
92
+ Assert . AreEqual ( "pk-testCC" , auth . ApiKey ) ;
112
93
113
94
auth = new OpenAI_API . APIAuthentication ( "sk-testBB" ) ;
114
- Assert . IsNotNull ( auth . Secretkey ) ;
115
- Assert . IsNull ( auth . APIKey ) ;
116
- Assert . AreEqual ( "sk-testBB" , auth . Secretkey ) ;
117
- auth = "sk-testDD" ;
118
- Assert . IsNotNull ( auth . Secretkey ) ;
119
- Assert . IsNull ( auth . APIKey ) ;
120
- Assert . AreEqual ( "sk-testDD" , auth . Secretkey ) ;
95
+ Assert . IsNotNull ( auth . ApiKey ) ;
96
+ Assert . AreEqual ( "sk-testBB" , auth . ApiKey ) ;
121
97
}
122
98
123
99
}
0 commit comments